Hello all,
Is it possible to do eager loading of association extensions?
That is, the following code produces one SQL query:
cat = ProductCategory.find(:first, :include => :pricing_rules)
cat.pricing_rules
But if in ProductCategory I have an association extension like this:
has_many :pricing_rules do
def applicable()
find(:all).select(&:applicable?)
end
end
the code
cat = ProductCategory.find(:first, :include => :pricing_rules)
cat.pricing_rules.applicable
will produce 2 queries anyway, :include is useless here.
I see no other way that to add another association:
has_many :applicable_pricing_rules :conditions => ''appliccable is
true''
and then use it:
cat = ProductCategory.find(:first, :include => :applicable_pricing_rules)
cat.applicable_pricing_rules
But maybe there''s a way to eagerly load an association extension?
--
Best regards,
Yuri Leikind
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---