Many-to-many with extra fields


#1

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


#2

On Tue, Jan 17, 2006 at 04:30:18PM -0500, Kyle M. 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