Skip to content

many to many relationship

December 1, 2010

There are two ways to going about it:

1. has_many_and_belongs_to

2. has_many :through

The second way to do it is almost a winner every time. So if in doubt, just do the second way. I do not see any advantages in the first, except may be in situations where you do not mind abstraction.

This railscast does a great job at explaining how to do them.

http://railscasts.com/episodes/47-two-many-to-many

Advertisements

From → Uncategorized

Leave a Comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: