Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add create_join_table migration helper to create HABTM join tables #4726

Merged
merged 1 commit into from Jan 27, 2012

Conversation

rafaelfranca
Copy link
Member

This helper was created as described here.

It can help to avoid issues like this #4653.

  • Docs and CHANGELOG line included

@josevalim
Copy link
Contributor

I like it. It will reduce the mistakes related to join tables a lot. If other core team members agree with this patch, we could even add a generator shortcut like: rails g migration join_table_users_and_labels (yes, I am a lazy bastard)


module ActiveRecord
class Migration
class CreteJoinTableTest < ActiveRecord::TestCase
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CreateJoinTableTest

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💣 Fixed. Thanks

@jeremy
Copy link
Member

jeremy commented Jan 27, 2012

Seems easy to forget that there's a special way to create join tables, though.

Could we solve the original problem by just populating timestamps on join tables, too?

tenderlove added a commit that referenced this pull request Jan 27, 2012
Add create_join_table migration helper to create HABTM join tables
@tenderlove tenderlove merged commit 69816a8 into rails:master Jan 27, 2012
@josevalim
Copy link
Contributor

@jeremy I am also fine with populating timestamps on join tables, although it seems @jonleighton doesn't like the idea much.

@jeremy
Copy link
Member

jeremy commented Jan 27, 2012

I'm not a fan of more complexity there either, but it feels worth being able to use a "stock" create_table as a join table.

Less for people to think about or look up in docs, and it's interchangeable with a has_many :through without migrating.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants