3 comments
If like me you are used to work with existing database schemas, the reverse_scaffold script should be interesting for you.
Just download it from GitHub and copy the file into the "script" folder of your Ruby on Rails application.
You can then execute it from your terminal :
$ ruby script/reverse_scaffold users user
For this example I presume you have an existing "users" table in your database described by the following columns :
In this case, the script will execute the command :
ruby script/generate scaffold user --skip-migration id:integer pseudo:string email:string password:string
As you understood, the first argument represents the name of the table and the second one is the name of the model to generate.
You can use the -V option if you don't want to execute the scaffold but just display the generated command.
If you are an RSpec adept, you can specify the -r option and rspec_scaffold will then be used.
For more information :
$ ruby script/reverse_scaffold -h
Add a comment
3 comments for this article
LLLLOOOOVVVVEEEEE IT!
great work thanks!
Written by Geekct on Tue Sep 01 18:35:21 UTC 2009
Just found this via google, etc - wanted to say it works great and thanks!
Written by sullivan.t on Mon Oct 12 14:58:19 UTC 2009
Juste une remarque en passant sur ce blog. C'est vraiment dommage que tu n'écrives pas plus souvent sur ton blog, car il est tout simplement fantastique et bourré d'exemples qui permettent à rails de s'intégrer plus facilement dans le monde de l'entreprise.
Au plaisir de te lire plus souvent
Written by Celesty on Wed Oct 21 07:50:02 UTC 2009