I need to get a subset of an objects collection. Sort of like
named_scope but for a specific model instance.
Foo has_many :bar
Bar has_many :buzz
I want all of the bars for a specific foo but I only want to consider
bars without buzz.
The best I can come up with is using a "select"
foo.bars.select { |bar| bar.buzzs.empty? }
Is there a better way to do this?
TIA
Sean
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---