Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Ruby

Brendan Whiting
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Brendan Whiting
Front End Web Development Techdegree Graduate 84,738 Points

Having trouble with this rails polymorphic migration challenge

I'm trying to do this challenge: https://teamtreehouse.com/library/active-record-associations-in-rails/more-association-options/a-migration-for-a-polymorphic-association, and I'm looking at the teachers notes from the previous video as a template: https://teamtreehouse.com/library/polymorphic-options

I tried both of these options, but neither works:

bin/rails g migration AddVehicleToPart vehicle_id:integer vehicle_type:string
bin/rails g migration AddVehicleToPart vehicle:references{polymorphic}

1 Answer

Maciej Czuchnowski
Maciej Czuchnowski
36,441 Points

OK, so this is the code that worked for me in the challenge:

rails g migration AddVehicleToParts vehicle_id:integer vehicle_type:string

You should use the plural name of the table to which you're adding stuff (Parts in this case), Rails will then infer that this is the name of the table in your database.

Nice! Thanks!