i.e. delete all the files it created and roll back any changes made? Not necessarily to the db, but more to the config files.
E.g. automatically deleting all the resource mappings for the model/controller deleted in the routes.rb file and everywhere else that changes might have been made?
Thanks.
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.
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:To reverse that, we just destroy it. Open Terminal application and go to project directory. Then, type this:
Where CamelCase is a name of any model or controller. It will remove model,migration and some of related test files. (You can see result on Terminal after you have run the command.)
We use generate as
rails generate app
. So regenerating anygenerate
statement can be reversed usingdestroy
statement. Just replacegenerate
withdestroy
i.e.rails generate app
can be written asrails destroy app'
rails generate ____as
rails destroy ____`This is prototype to generate or destroy a controller or model in rails.
for example, if you need to generate User Controller
or
if want destroy User controller or revert to above action then
or
to reverse rails generate, use rails destroy
https://guides.rubyonrails.org/command_line.html#rails-destroy