Question

Here is my Gemfile

gem 'rails', '3.0.0'
...
gem 'haml-rails'
gem 'jquery-rails'

group :test do
  gem 'shoulda'
  gem 'rspec'
  gem 'rspec-rails'
  gem 'factory_girl'
end

gem 'rails3-generators', :group => :development
...

I run bundle install/update. And then not all new generators (from rails3-generators) are added. haml generators are also missing:

artem:~/projects/merjis (master)$ rails g
...

Please choose a generator below.

Rails:
  controller
  generator
  helper
  integration_test
  mailer
  migration
  model
  observer
  performance_test
  plugin
  resource
  scaffold
  scaffold_controller
  session_migration
  stylesheets

ActiveRecord:
  active_record:devise

Authlogic:
  authlogic:session

Devise:
  devise
  devise:install
  devise:views

Jquery:
  jquery:install

Koala:
  koala:install

MongoMapper:
  mongo_mapper:install

Mongoid:
  mongoid:devise
  mongoid:install

Mustache:
  mustache:install

Rspec:
  rspec:install

What am I missing?

EDIT

As @shingara pointed, not all but only some generators are missing

Was it helpful?

Solution

Factory girl, shoulda and haml do not have 'explicit' generators you can call using rails generator. You need to configure your application. Haml is automatic (through the haml-rails gem, so from now on, each time a model is generated, it will generate haml views.

For the factory-girl you have to edit config\application.rb and add

# Configure generators values
config.generators do |g|    
  g.test_framework  :rspec, :fixture => true  
  g.fixture_replacement :factory_girl, :dir=>"spec/factories"
end

and shoulda you just need to require in your spec_helper.

OTHER TIPS

I am not familiar with the rails3-generators plugin but in your config/application.rb file

config.generators do |g|
  g.template_engine :haml => this works for sure
  g.scaffold_generator :rails3-generators => if that is the generator to replace
end

you can find another example here: http://paulbarry.com/articles/2010/01/13/customizing-generators-in-rails-3

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top