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

[docs fix] Indexing a polymorphic assoc adds index on type and id #19153

Merged
merged 1 commit into from
Mar 1, 2015
Merged

[docs fix] Indexing a polymorphic assoc adds index on type and id #19153

merged 1 commit into from
Mar 1, 2015

Conversation

stevelounsbury
Copy link
Contributor

The simplified way of creating a polymorphic association in a migration is:

t.references :imageable, polymorphic: true, index: true

This will create an index on [:imageable_id, :imageable_type].

The docs show how you can manually create the association instead of using t.references, but only show adding an index on :imageable_id.

seuros added a commit that referenced this pull request Mar 1, 2015
[docs fix] Indexing a polymorphic assoc adds index on type and id
@seuros seuros merged commit 1d10b4b into rails:master Mar 1, 2015
@stevelounsbury
Copy link
Contributor Author

Yep, you're right and that's how t.references :imageable, polymorphic: true, index: true generates it. Fixed in #19159

Thanks!

@arthurnn
Copy link
Member

arthurnn commented Mar 2, 2015

thanks @egilburg for noting that.

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

4 participants