Wednesday, November 21, 2012

Rails 3.x - Undoing commands

Controller and Action

In rails 3.x, To create a controller with actions we use this command

$ rails generate controller UserController add edit

If you want to remove the above controller and the actions

$ rails destroy controller User add edit


To create a model in rails 3

$ rails generate model User name:string mobile:string

This can be undone using

$ rails destroy model User

Database migration and rollback

To migrate the state of the database using

$ rake db:migrate

We can undo a single migration by this command

$ rake db:rollback

To go all the way back to the beginning by this command

$ rake db:migrate VERSION=0

These commands may be helpful for reverting controller, model and database migration specific changes.

No comments:

Post a Comment