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.
Suppose I have created a controller named sample like as
If I have to destroy this Controller, all I have to do is swap the generate with destroy, as in
If you want to reverse the generation, all you have to do is swap the 'generate' with 'destroy'
Before reverting the
rails generate
, please make sure you rollback the migration first.Case 1: if you want to revert scaffold then run this command -
Case 2: if you want to revert model then run this command -
Case 3: if you want to revert controller then run this command -
Note: you can also use shortcut
d
instead ofdestroy
Are you using version control (subversion, git, whatever)? Just revert. If not - why not?!!
You could use
rails d model/controller/migration ...
to destroy or remove the changes generated by using the rails generate command.Example:
rails g model Home name:string
creates a model namedhome
with attributename
. To remove the files and code generated from that command we can use the commandrails d model Home
.To delete the controller manually, in case the
rails d controller
command does not work:For controller
welcome
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.