public
Description: A collection of useful Rails generator scripts.
Homepage:
Clone URL: git://github.com/ryanb/nifty-generators.git
name age message
file .gitignore Tue Nov 11 14:29:23 -0800 2008 removing manifest file from repository since it... [ryanb]
file CHANGELOG Tue May 05 13:51:04 -0700 2009 marking version 0.2.4 for release [ryanb]
file LICENSE Tue May 06 10:19:51 -0700 2008 moving to echoe [Ryan Bates]
file README.rdoc Fri Oct 10 09:59:44 -0700 2008 adding a couple troubleshooting issues to readme [ryanb]
file Rakefile Tue May 05 13:51:04 -0700 2009 marking version 0.2.4 for release [ryanb]
file TODO Tue Nov 04 11:37:36 -0800 2008 removing extra white space in forms [ryanb]
directory lib/ Thu May 08 15:24:17 -0700 2008 adding lib directory just in case ruby gems req... [ryanb]
directory rails_generators/ Thu May 14 12:35:13 -0700 2009 Store request target location when login is req... [bensie]
directory script/ Tue May 06 15:27:07 -0700 2008 removing unused file in lib directory for now a... [ryanb]
directory tasks/ Thu May 08 15:22:04 -0700 2008 moving rake tasks into their own folder [ryanb]
directory test/ Tue May 05 10:45:47 -0700 2009 redirecting to root_url if index action doesn't... [ryanb]
README.rdoc

Nifty Generators

A collection of useful Rails generator scripts.

Install

  gem install nifty-generators

You may need to uninstall the older version if it’s installed.

  gem uninstall ryanb-nifty-generators

Usage

Once you install the gem, the generators will be available to all Rails applications on your system. If you run script/generate without any additional arguments you should see the available generators listed.

To run the generator, go to your rails project directory and call it using the script/generate or script/destroy command.

  script/generate nifty_scaffold Recipe name:string index new

Included Generators

  • nifty_layout: generates generic layout, stylesheet, and helper files.
  • nifty_scaffold: generates a controller and optional model/migration.
  • nifty_config: generates a config YAML file and loader.
  • nifty_authentication: generates user model with sign up and log in.

Run the command with the —help option to learn more.

  script/generate nifty_layout --help

Troubleshooting

I get "undefined method ‘title’" error.

Try running nifty_layout, that will generate this helper method. Or you can just change the templates to whatever approach you prefer for setting the title.

I get "undefined method ‘root_url’" error.

Some generators default redirecting to the root_url. Set this in your routes.rb file like this (substituting your controller name).

  map.root :controller => 'foo'

I get a missing database error.

Run rake db:migrate.

Forms don’t work.

Try restarting your development server. Sometimes it doesn’t detect the change in the routing.

I can’t set new attributes in my User model.

Add the attribute to the attr_accessible line in the model.

The tests/specs don’t work.

Make sure you have mocha installed and require it in your spec/test helper.

  gem install mocha

  # in spec_helper.rb
  config.mock_with :mocha

  # in test_helper.rb
  require 'mocha'

Also, make sure you’re using Rails 2.1 or greater.

Development

This project can be found on github at the following URL.

github.com/ryanb/nifty-generators/

If you wish the generators behaved differently, please consider forking the project and modifying to your heart’s content.