/nested-scaffold

Nested scaffold generator for Rails with support for RSpec, Test::Unit and Shoulda

MIT LicenseMIT

Nested Scaffold Generator

Generates a nested scaffold

Install

gem install nilesh-nested-scaffold -s https://gems.github.com

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

gem uninstall nilesh-nested-scaffold

Usage

Once you install the gem, the generator 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 nested_scaffold Blog/Post title:string index new

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

script/generate nested-scaffold --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/nilesh/nested-scaffold/

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