How to reverse a 'rails generate'

前端 未结 17 1264
一个人的身影
一个人的身影 2020-12-02 03:10

I want to delete all the files it created and roll back any changes made, but not necessarily to the database, but more to the config files.

I\'d like to automatical

相关标签:
17条回答
  • 2020-12-02 03:47
    rails destroy controller lalala
    rails destroy model yadayada
    rails destroy scaffold hohoho
    

    Rails 3.2 adds a new d shortcut to the command, so now you can write:

    rails d controller lalala
    rails d model yadayada
    rails d scaffold hohoho
    
    0 讨论(0)
  • 2020-12-02 03:48

    If you use Rails, use rails d controller Users.

    And, if you use Zeus, use zeus d controller Users.

    On the other hand, if you are using git or SVN, revert your changes with the commit number. This is much faster.

    0 讨论(0)
  • 2020-12-02 03:50

    All versions of rails have a "destroy", so-, if you create a (for example) scaffold named "tasks" using a generator, to destroy all the changes of that generate step you will have to type:

    rails destroy scaffold Tasks
    

    Hope it helps you.

    0 讨论(0)
  • 2020-12-02 03:51

    To reverse that, we just destroy it. Open the Terminal application and go to the project directory, then, type this:

    rails destroy model CamelCase
    rails destroy controller CamelCase
    

    Where CamelCase is a name of any model or controller. It will remove the model, migration and some of the related test files. (You can see the result in the Terminal window after you have run the command.)

    0 讨论(0)
  • 2020-12-02 03:54

    To reverse rails generate, use rails destroy:

    rails destroy Model
    

    See "rails destroy" for more information.

    0 讨论(0)
  • 2020-12-02 03:56

    rails destroy controller Controller_name was returning a bunch of errors. To be able to destroy controller I had to remove related routes in routes.rb. P.S. I'm using rails 3.1

    0 讨论(0)
提交回复
热议问题