Thanks for the great response, that''s just what I was looking for.
- Kyle
On Jan 19, 2006, at 11:11 AM, Cody Fauser wrote:
> Kyle,
>
> The :through option is the new support for join models. This
> allows you to do:
>
> class Person < ActiveRecord::Base
> has_many :memberships
> has_many :organizations, :through => :memberships
> end
>
> class Membership < ActiveRecord::Base
> belongs_to :person
> belongs_to :organization
> end
>
> class Organization < ActiveRecord::Base
> has_many :memberships
> has_many :members, :class_name => ''Person'', :through
=> :memberships
> end
>
> now you can do:
> p = Person.find(:first)
> p.organizations
>
> or the opposite:
> o = Organization.find(:first)
> o.members
>
> Also check out Rick Olson''s tip:
> http://rails.techno-weenie.net/tip/2005/12/23/
> teaching_your_blog_model_new_tricks_with_has_many_through
>
>
>
> Cody
>
>
> On 1/19/06, Kyle Mathews <kyle@titaniumdev.com> wrote:
>> Has anyone had much experience using the new has_many :though options
>> that are currently in Edge Rails? I''m looking at using it in
my
>> project but haven''t found much about it.
>>
>> Kyle
>>
>> _______________________________________________
>> Rails mailing list
>> Rails@lists.rubyonrails.org
>> http://lists.rubyonrails.org/mailman/listinfo/rails
>>
>
>
> --
> http://www.codyfauser.com
> _______________________________________________
> Rails mailing list
> Rails@lists.rubyonrails.org
> http://lists.rubyonrails.org/mailman/listinfo/rails