Rails 4 add a new column or field to the model

I am trying to add a new column to an existing model in rubyonrails. How to add one or more fields to an existing model.

+4
source share
1 answer

if you want to add a new column,

start the rail generator with the addition of [column] to the format [model], followed by the column

$ rails g migration AddBioToNameOfModels bio:text
invoke  active_record
create    db/migrate/YYYYMMDDHHMMSS_add_bio_to_name_of_models.rb

then run

rake db:migrate
+2
source

All Articles