Sylar Sylar - 4 months ago 6
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?


No not necessary. You can do

Assuming TableName is user

rails g migration AddColumnsToUser col1:integer col2:integer .. etc.