I have a situation where an instance method pulls out a selection from a set of associated objects. Sometimes when this is called the associated objects have been eager loaded, in which case it makes most sense to use .select to pull the ones i want from the already-loaded collection. Other times the associated objects have *not* been eager loaded, and it makes most sense to use association.find to get the ones i want. My question is this: can i tell if the associated objects have been eager loaded already, so i can choose which approach to take? Or, even better, is there a single approach where rails will know whether to load them again or not? thanks, max -- Posted via http://www.ruby-forum.com/. -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On Jul 14, 3:30 pm, Max Williams <li...-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> I have a situation where an instance method pulls out a selection from a > set of associated objects. Sometimes when this is called the associated > objects have been eager loaded, in which case it makes most sense to use > .select to pull the ones i want from the already-loaded collection. > Other times the associated objects have *not* been eager loaded, and it > makes most sense to use association.find to get the ones i want. > > My question is this: can i tell if the associated objects have been > eager loaded already, so i can choose which approach to take? Or, even > better, is there a single approach where rails will know whether to load > them again or not? >if it''s a collection then foo.bars.loaded? Fred> thanks, max > -- > Posted viahttp://www.ruby-forum.com/.-- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
ahh yes. perfect. thanks for the thousandth time Fred :) -- Posted via http://www.ruby-forum.com/. -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.