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
We use generate as
rails generate app.
So regenerating any generate statement can be reversed using destroy statement.
Just replace generate with destroy
i.e. rails generate app can be written as rails destroy app'
rails generate ____asrails destroy ____`
It's worth mentioning the -p flag here ("p" for pretend).
If you add this to the command it will simply do a "test" run and show you what files will be deleted without actually deleting them.
$ rails d controller welcome -p
remove app/controllers/welcome_controller.rb
invoke erb
remove app/views/welcome
invoke test_unit
remove test/controllers/welcome_controller_test.rb
invoke helper
remove app/helpers/welcome_helper.rb
invoke test_unit
remove test/helpers/welcome_helper_test.rb
invoke assets
invoke coffee
remove app/assets/javascripts/welcome.js.coffee
invoke scss
remove app/assets/stylesheets/welcome.css.scss
If you're happy with it, run the command again without the -p flag.
You can revert your
rails g/generate controller/model/migration xxx
output by using:
rails d/destroy controller/model/migration xxx
You can undo a rails generate in the following ways:
rails destroy MODEL rails destroy controller_nameIf you prefer to delete the controller manually:
For controller welcome
rm app/controllers/welcome_controller.rb
rm app/views/welcome
rm test/controllers/welcome_controller_test.rb
rm app/helpers/welcome_helper.rb
rm test/helpers/welcome_helper_test.rb
rm app/assets/javascripts/welcome.js.coffee
rm app/assets/stylesheets/welcome.css.scss
Removed scaffolding for selected model:
bin/rails d scaffold <AccessControl> //model name