• This repository has been archived on 12/Dec/2021
  • Stars
    star
    1,984
  • Rank 23,353 (Top 0.5 %)
  • Language
    Ruby
  • License
    MIT License
  • Created over 16 years ago
  • Updated almost 3 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A collection of useful Rails generator scripts.

Unmaintained

The Nifty Generators project is no longer maintained. Feel free to fork the project.

Nifty Generators

A collection of useful Rails generator scripts for scaffolding, layout files, authentication, and more.

Setup

Rails 3

Add the gem to your Gemfile.

gem "nifty-generators", :group => :development

Then you can run any of the included generators.

rails g nifty:scaffold Recipe name:string index new

Rails 2

First install the gem.

gem install nifty-generators

The generators will be available in all Rails applications. 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

Note an underscore is used instead of a colon for the Rails 2 generators.

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.

rails g 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.

rails g 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).

root :to => "home#index"

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.

Project Status

Unfortunately I have not had time to actively work on this project recently. If you find a critical issue where it does not work as documented please ping me on Twitter and I’ll take a look.

Found a bug?

If you are having a problem with Nifty Generators, first look at the FAQs above. If you still cannot resolve it, please submit an issue here.

github.com/ryanb/nifty-generators/issues

Development

If you want to contribute to this project, you can download the Git repository and get the Cucumber features running by calling bundle then rake. I normally develop this using Ruby 1.9.2 however it should work with 1.8.7 as well.

The Rails 3 generators are located under lib/generators and are tested with Cucumber. The older Rails 2 generators are under rails_generators and are tested with Shoulda under the test directory.

More Repositories

1

cancan

Authorization Gem for Ruby on Rails.
Ruby
6,265
star
2

ruby-warrior

Game written in Ruby for learning Ruby.
Ruby
3,830
star
3

letter_opener

Preview mail in the browser instead of sending.
Ruby
3,686
star
4

dotfiles

config files for zsh, bash, completions, gem, git, irb, rails
Shell
2,312
star
5

nested_form

Rails plugin to conveniently handle multiple models in a single form.
Ruby
1,792
star
6

private_pub

Handle pub/sub messaging through private channels in Rails using Faye.
Ruby
864
star
7

railscasts-episodes

NOT MAINTAINED. See README.
Ruby
846
star
8

railscasts

railscasts.com in open source (outdated).
Ruby
760
star
9

populator

Mass populate an Active Record database.
Ruby
393
star
10

complex-form-examples

Various ways to handle multi-model forms in Rails.
Ruby
304
star
11

trusted-params

Rails plugin for overriding attr_accessible protection.
Ruby
149
star
12

mustard

Simple "must" expectations for tests and specs in Ruby.
Ruby
144
star
13

govsgo

Rails 3 app for playing the board game Go online.
Ruby
140
star
14

xapit

High level Ruby library for interacting with Xapian, a full text search engine.
Ruby
139
star
15

rails-templates

Template scripts for creating new rails applications.
Ruby
134
star
16

cocoa-web-app-example

A Cocoa application to demonstrate the interaction between Objective-C and JavaScript in a WebView.
Objective-C
96
star
17

importex

Import an Excel file using Ruby.
Ruby
90
star
18

uniquify

Generate a unique, random token for Active Record.
Ruby
87
star
19

textmate-themes

My TextMate themes (includes Railscasts theme)
69
star
20

acts-as-list

NOT MAINTAINED. Gem version of acts_as_list Rails plugin.
Ruby
65
star
21

abingo

Fork of A/Bingo plugin for Rails.
Ruby
55
star
22

railscasts-scripts

Scripts used internally when producing RailsCasts
Ruby
52
star
23

scope-builder

Build up named scopes conditionally.
Ruby
51
star
24

rmov

Ruby wrapper for the QuickTime C API.
C
48
star
25

render-caching

Cache render calls in Rails controllers.
Ruby
45
star
26

enlighten

Interactive ruby debugger in the browser.
Ruby
41
star
27

static_actions

Rails plugin to quickly make named routes for non-RESTful actions.
Ruby
39
star
28

searchify

Rails plugin to add extra searching functionality to models.
Ruby
37
star
29

selenium-on-rails

This repo is no longer maintained, see the official repository by paytonrules.
JavaScript
34
star
30

ryan-on-rails.tmbundle

Some TextMate snippets I use when working with Ruby and Rails.
26
star
31

dailystamp

Source code for my Rails Rumble 2009 submission
Ruby
23
star
32

url_formatter

Format and validate a URL in Active Record. Example gem for RailsCasts.
Ruby
18
star
33

association-freezer

Freeze a belongs_to association in Active Record.
Ruby
17
star
34

admiteer

Rails Rumble 2007 project by Jack Canty, Kelli Shaver, and Ryan Bates
17
star
35

todo-list.tmbundle

A simple TextMate bundle to manage a todo lists.
14
star
36

myideadrawer

Rails Rumble 2008 entry by Ryan Bates and Kelli Shaver
Ruby
13
star
37

advent-2022

Advent of Code in Elixir
Elixir
12
star
38

blog-screencast

Example blog application built in the offical 15 minute Rails screencast.
Ruby
12
star
39

xapit-sync

Rails plugin to automatically reload a Xapian database when models change.
Ruby
12
star
40

ryan-bates.tmbundle

Miscellaneous commands and snippets I use in TextMate.
11
star
41

maestro

Piano exercise game written in MacRuby.
Ruby
11
star
42

vscode-railscasts-theme

RailsCasts Theme for VS Code
7
star
43

ryanb.github.io

Personal site for Ryan Bates
5
star
44

vscode-erb-syntax

ERB Syntax for VS Code
5
star
45

xapit-server

Rack server for interacting with a Xapian database remotely through Xapit.
Ruby
4
star
46

swapper

Ruby script for swapping two elements on a line (to be used in text editors).
3
star
47

bookmarklets

JavaScript
1
star
48

wallaby-rails-7-1-2

Example Rails 7.1.2 app with Wallaby
Ruby
1
star