Sylar Sylar - 1 year ago 99
Ruby Question

Rails 4: Add Multiple Columns to Existing Table

I know how to add one column to an existing table. Now I have to add many columns to an existing table. Is there a shorter way for:

add_col1_col2_col3_col4_.._coln_to_tables col1:integer col2:integer etc...

Do I have to do the above for ALL the additional columns I have to add?

Answer Source

No not necessary. You can do

Assuming TableName is user

rails g migration AddColumnsToUser col1:integer col2:integer .. etc.
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download