Rails 4 add new column or field in model

后端 未结 1 962
一整个雨季
一整个雨季 2021-01-13 20:42

I try to add new column into existing model in rubyonrails. How can I add single or multiple field into my existing model.

相关标签:
1条回答
  • 2021-01-13 21:03

    if you want to add a new column then

    run rails generator with Add[column]To[model] format followed by 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
    
    0 讨论(0)
提交回复
热议问题