Pietro
2010-May-12 22:25 UTC
OT? Using Arel to generate table names in multiple self join query
Firstly I''m sorry if this is off-topic but I think it''s a question that won''t be answered without good core knowledge. I have written a multiple self join query something 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'' } } That''s fine insofar as it returns the desired result, but I am very unhappy with the prospect of having to hardcode assumptions about what the tables will be aliased with in the conditions and select (people, children_people, children_people_2, etc.). Is there some way I can write this making use of Arel so that the table names in the conditions are not hardcoded, and so is robust to a change in Arel''s naming algorithm? Thanks. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-core+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en.