HiveBrain v1.2.0
Get Started
← Back to all entries
snippetrubyCritical

How to reverse a 'rails generate'

Submitted by: @import:stackoverflow-api··
0
Viewed 0 times
generaterailshowreverse

Problem

I want to delete all the files it created and roll back any changes made, but not necessarily to the database, but more to the config files.

I'd like to automatically delete all the resource mappings for the model/controller deleted in the routes.rb file and everywhere else that changes might have been made?

Solution

rails destroy controller lalala
rails destroy model yadayada
rails destroy scaffold hohoho


Rails 3.2 adds a new d shortcut to the command, so now you can write:

rails d controller lalala
rails d model yadayada
rails d scaffold hohoho

Code Snippets

rails destroy controller lalala
rails destroy model yadayada
rails destroy scaffold hohoho
rails d controller lalala
rails d model yadayada
rails d scaffold hohoho

Context

Stack Overflow Q#4161357, score: 1011

Revisions (0)

No revisions yet.