Wednesday, May 06
Permalink

Rails and nested has_many :through

posted 7 months ago

Rails does not support nested has_many :though => associations. There is a plugin however which enables this, and JackDangers branch on github has patches for Rails 2.3.2.

script/plugin install git://github.com/JackDanger/nested_has_many_through.git

Which enables you to do the something like the following:



class User < ActiveRecord::Base

 has_many :accounts

 has_many :memberships,  :though => :accounts

 has_many :groups, :through => :memberships 

end
Comments (View)
blog comments powered by Disqus