A collection of useful Rails generator scripts.
Ruby JavaScript
Pull request Compare This branch is 11 commits ahead, 98 commits behind ryanb:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
lib
rails_generators
script
tasks
test
.gitignore
CHANGELOG
LICENSE
README.rdoc
Rakefile
TODO

README.rdoc

Nifty Generators

A collection of useful Rails generator scripts.

Install

To make/install as a gem:

git clone private url
rake manifest  
rake build_gemspec

Change the name in the nifty-generator.gemspec to minerva-nifty-generators

gem build nifty-generators.gemspec
gem install minerva-nifty-generators.gem

Usage

Do once when starting a new rails app

script/generate nifty_config
gem bundle
script/generate nifty_layout

An example of using nifty_scaffold

script/generate nifty_scaffold Recipe name:string

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.

To view the README for each generator, run it with the --help option.

script/generate nifty_layout --help

Troubleshooting and FAQs

What is the difference between nifty_scaffold and built-in scaffold?

One of the primary differences is that nifty_scaffold allows you to choose which controller actions to generate.

script/generate nifty_scaffold post name:string index new edit

There are a few changes to the generated code as well, such as no XML format by default.

It also offers support for HAML, Shoulda, and RSpec.

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 can't set new attributes in my model.

Add the attribute to the attr_accessible line in the model.

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.

I get a routing error when I try to submit a form.

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

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.