Rails Association

Spent a day learning how about associations.  Realized that has_and belongs to and the necessary join table isn’t as easy to use as creating a regular join model table and use has_many :through.

Join Table = create_join_table

Join Model Table = create_table

Following Railscast, it promoted to use join model along with has_many :through.  Part of the issue I had was that I wanted additional information in the join table like the timestamp information.  Especially for Many to Many relationships.


Originally I planned on using Rails migration to create all my tables.  After creating only 7 of them I feel like it is a bit overkill. Much easier to write my own sql script that creates a table and then just use the rake db:schema:dump.

If you want to use scaffold following the dump

rails g model ModelName –skip-migration




This entry was posted in RoR and tagged , , . Bookmark the permalink.

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 )

Google photo

You are commenting using your Google 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 )

Connecting to %s