jfs-generators
My collection of Ruby on Rails generators.
Install
If you have never grabbed a gem from github or you aren't sure if you have, run the following command: (you should only have to do this once):
gem sources -a http://gems.github.com
Once you have setup GitHub as a gem source, run this command to install the gem:
sudo gem install jfs-generators
Usage
Once you install the gem, the generators should be available to all Ruby on
Rails applications on your system. Run script/generate
without any arguments
to see a list of the available generators in your environment.
To run the generator, go to your rails project directory and call it using the
script/generate
or script/destroy
command. For example:
script/generate jfs_model Article title:string content:text
jfs_model
Stubs out a new model. Pass the model name, either CamelCased or under_scored,
and an optional list of attribute pairs as arguments. Attribute pairs are
column_name:sql_type arguments specifying the model's attributes. Timestamps are
added by default, so you don't have to specify them by hand as
created_at:datetime updated_at:datetime
.
This generates a model class in app/models
and a migration in db/migrate
.
Examples:
./script/generate jfs_model Account
creates an Account model at app/models/account.rb
and a migration at
db/migrate/XXX_add_accounts.rb
.
./script/generate model Article title:string content:text
creates an Article model with a string title and text body.
Copyright
Copyright (c) 2009 Jason Stahl. See LICENSE for details.