且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

在“引用"中指定列名移民

更新时间:2023-02-05 16:33:50

手动操作:

add_column :post, :author_id, :integer

但是现在,当你创建belongs_to语句时,你将不得不修改它,所以现在你必须调用

but now, when you create the belongs_to statement, you will have to modify it, so now you have to call

def post
    belongs_to :user, :foreign_key => 'author_id'
end