How do you write a migration to rename an ActiveRecord model and its table in Rails?

前端 未结 5 1450
忘掉有多难
忘掉有多难 2020-11-29 14:56

I\'m terrible at naming and realize that there are a better set of names for my models in my Rails app.
Is there any way to use a migration to rename a model and its cor

5条回答
  •  借酒劲吻你
    2020-11-29 15:41

    You can do execute this command : rails g migration rename_{old_table_name}to{new_table_name}

    after you edit the file and add this code in the method change

    rename_table :{old_table_name}, :{new_table_name}

提交回复
热议问题