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 trialMuhammad sharifi
4,455 Pointsanyone can tell me the correct command?
We need to be able to specify that a Part model belongs to either a Car or a Truck (which we will refer to as "vehicles"). Assume that cars and parts tables already exist. Here at the command line, generate a migration that will add vehicle_id and vehicle_type columns to the parts table.
3 Answers
Steve Hunter
57,712 PointsHi there,
For this you you need to use the rails generate
command to create a migration
. To tell the framework which table to modify, you can use title case to say, for example, AddColumnsToExample
where Example
is the table you are adding the columns to.
Next, specify the name of the column and the data type, separated by a colon. You're given these in the question. There's vehicle_id
which we can assume is an integer
and vehicle_type
which I called a string
.
Tying all that together and you should get through the challenge
Steve.
Nicolás Melgarejo
14,265 PointsI'm trying
rails g migration AddVehicleToPart vehicle_id:integer vehicle_type:string
Nico Fedorca
21,587 Pointsbin/rails g migration AddVehicleToParts vehicle_id:integer vehicle_type:string for me worked Parts instead of Part
Adriana Cabrera
14,618 PointsAdriana Cabrera
14,618 PointsThis is what works for me rails g migration AddVehicleToParts vehicle_id:integer vehicle_type:string