我有一个带有列的模型price.我需要添加一个new_column,marked_price其值为price默认值.我可以在迁移中写这个,或者最好的方法是什么?
就像是:
class AddMarkedPriceToMenuItems < ActiveRecord::Migration
def change
add_column :menu_items, :marked_price, :decimal, :default => :price
end
end
Run Code Online (Sandbox Code Playgroud)