Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Ruby ActiveRecord Basics Migrations and Relationships Migrations 2

Binu Alexander
Binu Alexander
4,081 Points

How to add 2 fields into migration from command line ?

How to add 2 columns in a single migration ?

rails generate migration AddDetailsToContacts first_name:string, last_name:string

2 Answers

Maciej Czuchnowski
Maciej Czuchnowski
36,440 Points

Removing the comma should do the trick.

Binu Alexander
Binu Alexander
4,081 Points

This is my code :rails generate migration AddDetailsToContacts first_name :string last_name :string

This is the error : The first argument should be the name of the table.

I removed the comma , still the error

Try putting in:

rails generate migration contacts first_name:string last_name:string

Maciej Czuchnowski
Maciej Czuchnowski
36,440 Points

Weird, it should assume contacts table by default from the name of the migration. Try:

rails generate migration add_details_to_contacts first_name:string last_name:string

Binu Alexander
Binu Alexander
4,081 Points

rails generate migration contacts first_name:string last_name:string

this is working