Hey everyone, I tried searching for this and asking in #rubyonrails but got no answer. Given: class Aye; has_many :bee; end class Bee; has_many :cees; end class Cee; has_many :dees end Is this possible?: aye.dees I know how that with has_many through you can get aye.cees but can it go further than that? While searching I came accross http://wiki.rubyonrails.org/rails/pages/ThroughAssociations that talked about it (but this was a wish): class Manufacturer # using an array specifies the order in which the relationships occur. has_many :review_comments, :through => [:products, :reviews] # For that matter, we should be able to string together as many relationships as we like. # For example, for intergalactic commerce, we might want to find out which moons are associated with a given manufacturer. has_many :moons, :through => [:distributors, :space_stations, :planets, :moons] end Thanks, Ramon Tayag --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
huard.elise-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
2009-Jan-07 10:30 UTC
Re: Deep has_many through
Hi, you provide your own answer :-) class Aye has_many :bees # plural ! has_many :cees, :through => :bees # this specifies which class is intermediary end class Bee has_many :cees end class Cee has_many :dees end And then you can use Aye.dees. Elise On Jan 7, 8:15 am, "Ramon Tayag" <ramon.ta...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hey everyone, > > I tried searching for this and asking in #rubyonrails but got no answer. > > Given: > class Aye; has_many :bee; end > class Bee; has_many :cees; end > class Cee; has_many :dees end > > Is this possible?: > aye.dees > > I know how that with has_many through you can get aye.cees but can it > go further than that? > > While searching I came accrosshttp://wiki.rubyonrails.org/rails/pages/ThroughAssociationsthat > talked about it (but this was a wish): > class Manufacturer > # using an array specifies the order in which the relationships occur. > has_many :review_comments, :through => [:products, :reviews] > # For that matter, we should be able to string together as many > relationships as we like. > # For example, for intergalactic commerce, we might want to find out > which moons are associated with a given manufacturer. > has_many :moons, :through => [:distributors, :space_stations, > :planets, :moons] > end > > Thanks, > Ramon Tayag--~--~---------~--~----~------------~-------~--~----~ 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@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---