search for: eagerloadpolymorphicerror

Displaying 2 results from an estimated 2 matches for "eagerloadpolymorphicerror".

2006 Mar 31
2
Eager loading of polymorphic associations
Polymorphic associations work great until I try to do some eager loading through :include. In my example, the interface name is ":imagehaver". Here''s my little eagerly loading find line: Image.find(params[:id], :include => :imagehaver) All it gives me is an ActiveRecord::EagerLoadPolymorphicError with no further explanation. I haven''t been able to dig up anything useful through Google, so I''m worried (or hoping?) that it could just be my code. Any ideas? Cheers. -- http://www.mans.de
2007 Mar 29
21
a better "should have valid associations"
...) @failed_association = nil @model_class = model.class model.class.reflect_on_all_associations.each do |assoc| begin model.send(assoc.name, true) model.class.send(''find'', :first, :include => assoc.name) rescue ActiveRecord::EagerLoadPolymorphicError # nothing. Can''t find :include a polymorph. This requires a better test. rescue => err @failed_association = "#{assoc.name} // #{err}" end end !@failed_association end def failure_message "invalid association...