Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Undo scaffolding in Rails

Is there any way to 'undo' the effects of a scaffold command in Rails?

like image 346
Daniel Avatar asked Jun 08 '09 04:06

Daniel


People also ask

How do I undo a build 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.)

What is scaffolding in rails?

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.


2 Answers

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.

like image 53
8 revs, 7 users 47% Avatar answered Oct 06 '22 23:10

8 revs, 7 users 47%


Rishav Rastogi is right, and with rails 3.0 or higher its:

 rails generate scaffold ... 
 rails destroy scaffold ... 
like image 36
Misha Rabinovich Avatar answered Oct 06 '22 23:10

Misha Rabinovich