Undo scaffolding in Rails

Viewed 144437

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

25 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.

rails d scaffold <scaffoldname>

Also, make sure you undo the migration you made either by rollback or to a particular version.

rails [option] scaffold scaffold_name

Option

g    generate
d    destroy

If you do

rails g  scaffold myFoo

Then reverse it back using

rails d scaffold MyFoo

To generate:

rails g scaffold post
rake db:migrate

To delete:

rake db:rollback
rails d scaffold post
Related