Arun Agrawal’s Blog

Ruby on Rails Developer


Bundler is a preferred way to manage your Rails application gem decencies. In Rails3 the bundler comes by default. Gemfile is the place where we need to tell about our gems. Example file looks like
gem "rails", "~> 3.0.1"
gem "mongo", "1.1.5"
gem "bson", "1.1.5"
gem "bson_ext", "1.1.5"
gem "mongoid", :git => ""
gem "devise"
gem "haml"
group [:test, :development] do
 gem 'ruby-debug'
group :test do
 gem "rspec", "~> 2.0.0"
 gem "rspec-rails", "~> 2.0.0"
 gem "shoulda"
 gem "factory_girl"
 gem "faker"
Here we can define number of groups according to our environments. As you can see above example ‘ruby-debug’ will only get loaded when you are in development and test environment. ‘rspec’, ‘faker’ will gets loaded in test environment only. So this is a cool way to manage your gem dependencies. And ‘rails’, ‘mongo’, ‘bson’ all other ungrouped gems gets loaded in all environment.