我有一个现有模型'micropost',我发现模型的名称更适合我的应用。在不影响其索引的情况下,将'micropost'模型重命名为'story'模型会更好吗?我正在使用Rails 5.0.0.rc1。迁移片段为:带迁移的重命名模型
class CreateMicroposts < ActiveRecord::Migration
def change
create_table :microposts do |t|
t.text :content
t.references :user, index: true
t.timestamps null: false
end
add_index :microposts, [:user_id, :created_at]
end
end
如果数据库在本地,然后去chnage所有的名字根据自己的需要,否则,创建一个迁移重命名同样的事情。 –
@Bharatsoni感谢您的及时回复。我应该使用up和down方法吗?还是有更好的方法? – veekram