search for: hasmanyassociation

Displaying 4 results from an estimated 4 matches for "hasmanyassociation".

Did you mean: has_many_association
2006 Feb 10
1
Auto-generated find queries adding bogus WHERE clauses
[Sorry for the poor subject; this is really hard to explain] I''m trying to run a search over several objects which themselves contain multiple model objects, like so: class Collection << ActiveRecord::Base def findpkg self.repositories.each do |r| p = r.packages.find(:all, :conditions => "name like ''%pkg%''") end end end
2006 Jul 31
3
Polymorphic associations and single table inheritance
...stroy end class Member < Person end Adding an Address to a Member results in the addressable_type column equaling "Person" when it should be "Member". Looking in ActiveRecord::Associations::AssociationProxy#set_belongs_to_association_for and ActiveRecord::Associations:: HasManyAssociation#construct_sql it''s clear why. >From ActiveRecord::Associations::AssociationProxy#set_belongs_to_association_for: record["#{@reflection.options[:as]}_type"] = @owner.class.base_class.name.to_s Removing the call to base_class results in the behavior I expected. I did this...
2010 Jul 14
1
ActiveRecord::Observer, update_all and has_many
...ver, I''ve noted that adding an item to a has_many relationship gets logged, but removing the item does not. That is: @product.users << user is logged, but: @product.users.delete(user) is not. I''ve dug into ActiveRecord and found that the underlying issue is that the HasManyAssociation delete_records method uses update_all to update the record. update_all bypasses the normal call backs and therefore also bypasses the Observer. Is there a way to get an Observer to observe update_all calls? -- Posted via http://www.ruby-forum.com/. -- You received this message because you are s...
2009 May 27
12
query on Ruby array
Looking for suggestions on following two queries. Query 1 ------------------------------ Are the two following lines of code different in Ruby / Rails ( in a *.html.erb) file. <% if @forms.count != 0 %> <!-- first code --> Vs. <% if @forms.count %> <!--second code --> @forms is an array of objects. Coming from "C" language development background, i thought