5
我有一个移民类项目这样在轨
class CreateProjects < ActiveRecord::Migration
def change
create_table :projects do |t|
t.string :title
t.text :description
t.boolean :public
t.references :user, index: true, foreign_key: true
t.timestamps null: false
end
end
end
它会在项目表中的列名user_ID的更改外键的列名,但我想的名字列owner_id这样我就可以使用project.owner代替用户。
我很高兴地发现,'rename_column'也需要重命名索引的护理。 – Subtletree
您还可以使用''change_table'](http://apidock.com/rails/ActiveRecord/ConnectionAdapters/SchemaStatements/change_table)'t.rename' –
我得到未知属性'new_id'? –