DAZ wrote: > I have a family-tree structure to a person model. > > I want to be able to find people by specifying an array that > corresponds to the family tree. So if Abe is grandpa, homer is dad and > bart is the son, bart's array would be [abe,homer,bart].
Your requirement probably exceeds ActiveRecord's DSL. Even if you did this... class Person has_many :children has_many :grand_children, :through => :children (with the :class_name => Person and whatnot) ...you cannot stitch them together in a find statement. You could of course :include => [:children, :grand_children], but then there's no way to distinguish from three instances of the same table in your :conditions fields. You must hit either 'name' or 'persons.name', but then 'persons' is ambiguous. And even if all that worked, you then can't handle a variable length array. The best bet is to count the elements in the array, then build a :joins string that pulls in and numbers the persons table that number of times. Sketch what you need in raw SQL first, such as in a query editor. Then build a :conditions string (possibly using named replacements - :conditions => ['yack yack', {:name1 => name[1], :name2 => name[2], etc}]) that stamps in each name. -- Phlip --~--~---------~--~----~------------~-------~--~----~ 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@googlegroups.com To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---