Where is the CleanUp method? - subsonic3

I'm working fine with Subsonic 3 and the templates until november 2009. Now I'm geting the source directly from Git, but the ActiveRecord template doesn't generates correctly anymore. In the line 334 of the ActiveRecord template for SQLite:
return from items in repo.GetAll()
where items.<#=CleanUp(fk.OtherColumn)#>
== <#=CleanUp(fk.ThisColumn)#>
Error: The name 'CleanUp' doesn't exist in the current context
But I can't find the CleanUp method in the Subsonic.Core project. Someone knows something about this?

I have no more remedy than a version of the method to Settings.ttinclude. Now Structs.tt doesn't generates.

Related

Toggle! Bang Change in Rails 4

Trying to solve a mystery for the purpose of documentation.
We're upgrading from Rails 3.2 to Rails 4.
In the Rails 3.2 code, we have (well, had):
def update_object_special_eligibility
object.toggle!(:can_run_on_special) if object && object.can_run_on_special? && ineligible_for_special?
end
I realize this doesn't give you all the information you need, but here is the error. You should know that can_run_on_special is a bitfield rather than an official attribute, though I don't think it's actually relevant. Just thought I'd let you know why we were getting the error:
1) Error:
ObjectStatusTest#test_should_mark_object_as_not_eligible_to_run_on_special_for_specific_unschedule_reasons:
ActiveModel::MissingAttributeError: can't write unknown attribute `can_run_on_special'
config/initializers/acts_as_audited.rb:280:in `write_attribute_with_audit'
app/models/object_status.rb:437:in `update_deal_amazon_eligibility'
test/unit/object_status_test.rb:481:in `block in <class:ObjectStatusTest>'
test/fast_test_helper.rb:99:in `call'
test/fast_test_helper.rb:99:in `block in <class:TestCase>'
The code we changed it to that works on Rails 4:
def update_object_special_eligibility
if object && object.can_run_on_special? && ineligible_for_special?
object.update_attributes! :can_run_on_special => false
end
My suspicion is that because toggle! operates like update_attribute in terms of bypassing validations that it's just returning false for saving the attribute, and therefore, toggle! just doesn't work anymore because the updating of the attribute and the saving isn't working. But I am not sure that's the case. I'm hoping someone out here might have some idea about why this ActiveRecord::Persistence method (toggle!) might be operating differently in Rails 4. Or, is it the updating of the "attribute" and saving that is likely operating differently?
Thanks so much!
Looks like acts_as_audited is getting in on the act, and isn't bitfield/toggle savvy, would be my guess. Too many cooks hacking in their wares here. (bitfield and acts_as_audited).

Where is my partial name getting cached?

I am trying to do some refactoring but am not able to move my partial without getting a missing template error from the calling template. I renamed and moved the partial, then in the calling template, I changed from:
= render 'slot_fields', f: builder
To:
= render 'slots/slot_create_fields', f: builder
But I get the error:
Missing partial sheets/_slot_fields, application/_slot_fields
I have tried restarting the Rails server and cntl-F5 to reload the page but I am stuck. Thanks in advance for your help.
Rails templates are not cached by default.
It could be possible that your templates get precompiled by the Rails Asset Pipeline.
Try to clean all the precompiled assets with the following
rake assets:clobber
Thanks all for the help but I just figured it out. I was referring to the partial somewhere else (a link_to helper).

Auto-generated rspecs

I am working on an existing RoR app which was written a few years ago. It's testers were less than satisfying so the whole /spec directory was removed and I have to write new rspecs. I have seen somewhere that it is possible to generate non-blank rspecs using scaffold method. When I tried doing
rails generate scaffold rspec:model User
I got the lovely result of
invoke active_record
/home/guy/railsProjects/netAdmin/vendor/ruby/2.0.0/gems/railties-4.1.6/lib/rails/generators/base.rb:258:in `const_defined?': wrong constant name Rspec:model (NameError)
from /home/guy/railsProjects/netAdmin/vendor/ruby/2.0.0/gems/railties-4.1.6/lib/rails/generators/base.rb:258:in `block in class_collisions'
how do I work it out? having something that will write some of the specs, based on the existing models and controllers will save me tons of time.
Thanks in advance!

Rails3: Find method not working with fixtures in test environment

The Rails Guide says, "Fixtures can also transform themselves into the form of the original class. Thus, you can get at the methods only available to that class," and gives the example,
# using the find method, we grab the "real" david as a User
david = users(:david).find
My fixtures are working ok, but when I try
memb = members(:one).find
I get an error: NoMethodError: undefined method `find'. What am I doing wrong?
(Rails Guide reference: http://edgeguides.rubyonrails.org/testing.html#the-low-down-on-fixtures)
The guide is fixed now, and find is not necessary anymore because now users(:david) is the ActiveRecord object.

Unit Testing with SubSonic, ActiveRecord and SqlQuery

I'm trying to use the built-in testing features of Subsonic 3.0.0.4 by setting my connection string to "Test". My data access routines use the SqlQuery class. When I try to run a test against the "in-memory" repository, I receive this error:
System.ArgumentException: Format of
the initialization string does not
conform to specification starting at
index 0.
When debugging, I can see that the database class, which inherits from IQuerySurface, is in test mode.
Is it possible to use the built-in testing feature in Subsonic with ActiveRecord and SQLQuery?
Is it possible to use the built-in testing feature in Subsonic with ActiveRecord and SQLQuery?
No the built-in testing only works with Linq queries