Removing a model from your rails project
During the work on a project I created a model. Right after clicking the Enter key I realized that I didn’t need it and wanted to roll back.
Because I am using GIT, I could of course have done this using it, but I wanted to do it using a Rails command.
Turns out, there’s a command to do this (if you haven’t migrated the db yet).
The command is as follows:
script/destroy model contact
This will remove all of the files that were added by this command.
script/generate model contact user_id:integer type:integer
Nice to know you can either do this with GIT or with Rails. Obviously the best solution is to think before you click Enter but it’s nice to know nevertheless.Submit to Hacker News
[NOTE] This post has been imported to Hugo from a Wordpress blog. It may be broken, missing images, code snippets or other information.
[NOTE] updated November 24, 2010. It's 2987 days old . This article may have outdated content.