Is there any way to 'undo' the effects of a scaffold command in Rails?
To undo a rails generate command, run a rails destroy command. You can then edit the file and run rake db:migrate again. (See how to roll back a Migration file to rollback a specific migration or multiple migrations.)
Rails scaffolding is a quick way to generate some of the major pieces of an application. If you want to create the models, views, and controllers for a new resource in a single operation, scaffolding is the tool for the job.
First, if you have already run the migrations generated by the scaffold
command, you have to perform a rollback first.
rake db:rollback
You can create scaffolding using:
rails generate scaffold MyFoo
(or similar), and you can destroy/undo it using
rails destroy scaffold MyFoo
That will delete all the files created by generate
, but not any additional changes you may have made manually.
Rishav Rastogi is right, and with rails 3.0 or higher its:
rails generate scaffold ...
rails destroy scaffold ...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With