Kaleem Ullah's Blog

Configure haml & factory_girl as default generator in Rails 3

Posted in Rails by Kaleem Ullah on August 10, 2011

Rails 3.0 didn’t provide facility to set haml & factory_girl as default generators but these can be set via 2 gems.
Its very simple to add those.
In Gemfile, add

gem "haml-rails"
gem "rails3-generators"

In config/application.rb,

config.generators do |g|
g.fixture_replacement :factory_girl, :dir => 'spec/factories'
end

(I assume you already installed haml, rspec-rails, factory_girl_rails gems)

That’s it. Now if you generate scaffold then by default you will have views as haml and fixture as factory.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: