Forum: Ruby on Rails many-to-many with extra fields

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
5dd60445347fc3dec62474cc732fef0d?d=identicon&s=25 Kyle Mathews (Guest)
on 2006-01-17 23:08
(Received via mailing list)
I'm trying to work with a many-to-many relationship, but the join
table needs to have a is_primary field. What is the best way to work
with this (adding / changing primary / deleting)? I understand that
the :through option in Edge Rails can handle this better, but I was
just wondering if there was a good way to handle this with Rails 1.0.

Thanks,
Kyle
Cee0292fffa691f1fb320d5400200e99?d=identicon&s=25 Marcel Molina Jr. (Guest)
on 2006-01-17 23:11
(Received via mailing list)
On Tue, Jan 17, 2006 at 04:30:18PM -0500, Kyle Mathews wrote:
> I'm trying to work with a many-to-many relationship, but the join
> table needs to have a is_primary field. What is the best way to work
> with this (adding / changing primary / deleting)? I understand that
> the :through option in Edge Rails can handle this better, but I was
> just wondering if there was a good way to handle this with Rails 1.0.

You can create two has_many relationships and an intermediary join
model:
http://vernix.org/marcel/2has_many.rb.txt

In the example above, you have a full join model in the Subscription
class.

marcel
This topic is locked and can not be replied to.