Rail3 Arel finders are just great, but you can''t find a lot of example on how powerful they really are. I made a discovery, just experimenting with some chaining. List say you have Foo has may Bars @foo = Foo.find(1) @bar = @foo.bars That would give you all the bars related to foo(1) But you can also do: @bar = @foo.bars.order(:name).where(:elem => "something") I guess it is like scopes, just not defined in the model. I don''t know if that was possible in rails2 (e.g., @bar @foo.bars.find(:conditions => "xxx")) Not sure I have a use for it, but it was interesting that you can filter a nested has_many relationship. Steve Alex -- 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 Aug 18, 5:18 am, AppleII717 <sa...-ee4meeAH724@public.gmane.org> wrote: \>> I don''t know if that was possible in rails2 (e.g., @bar > @foo.bars.find(:conditions => "xxx")) > > Not sure I have a use for it, but it was interesting that you can > filter a nested has_many relationship.I guess it was a learning experience for me. I don''t think I every saw an example where you can filter a nested relation. Tried it in rails 2.3.8 and it worked - so it was not a discovery - except for me. -- 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.
Also note that you can chain "magic finders" off the association as well; so @foo.bars.find_by_name(''xyzzy'') will work. --Matt Jones On Aug 18, 7:35 am, AppleII717 <sa...-ee4meeAH724@public.gmane.org> wrote:> On Aug 18, 5:18 am, AppleII717 <sa...-ee4meeAH724@public.gmane.org> wrote: > \> > > > I don''t know if that was possible in rails2 (e.g., @bar > > @foo.bars.find(:conditions => "xxx")) > > > Not sure I have a use for it, but it was interesting that you can > > filter a nested has_many relationship. > > I guess it was a learning experience for me. I don''t think I every saw > an example where you can filter a nested relation. Tried it in rails > 2.3.8 and it worked - so it was not a discovery - except for me.-- 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.