Pietro Mas
2010-May-12 19:46 UTC
Dynamically constructing conditions in multiple self join
Hi, I am using a join that looks like this: Person.find :all, :select => ''children_people_3.*'', :joins => { :children => { :children => :children } }, :conditions => { :people => { :name => ''tom'' }, :children_people => { :name => ''dick'' }, :children_people_2 => { :name => ''harry'' }, :children_people_3 => { :name => ''charles'' } } which I don not like because I am hard-coding assumptions about the table aliases used for the joins into the conditions. Can someone tell me how to write the conditions in a more flexible way (can they be specified using the hash syntax?), or possibly tell me how I could try use the Arel being used to construct the query by the Rails core to construct the table aliases that I am hard-coding above. Rails 3.0.0.beta. Thanks. -- 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.