创建模型后向模型添加列

Adding a column to a model after the model is created

在 Rails 中创建模型时,我忘记添加我想要的列“strong text”。以后如何将其添加到模型中?

在你的命令行中 rails g migration add_strong_text_to_model strong_text:stringrake db:migrate

this 的副本

console/terminal上写一个迁移如下:

rails g migration AddColumnToModel column_name:column_type

然后 运行 迁移 console/terminal 为:

rake db:migrate