What is the best way to drop a table & remove a model in Rails 3?

后端 未结 2 1839
离开以前
离开以前 2020-12-12 16:17

I have a model & a table which I no longer need in my App, I could leave them there but I would like to remove them to keep things tidy.

I\'m trying to figure out

2条回答
  •  無奈伤痛
    2020-12-12 16:55

    I know this is an old thread. More often than not, you want to remove not only the model, but routes, controller and views associated with that model as well. To do that, run these

    rails g migration DropYourModel
    rails destroy scaffold YourModelName
    

    Edit your migration file to drop_table and then run

    rake db:migrate
    

    If the model happens to be defined in a namespace, e.g., admins, replace the first command with

    rails destroy scaffold admins/YourModelName
    

提交回复
热议问题