Last Updated: February 25, 2016
·
693
· grekko

Developer specific gems for Rails development

Introduction

You should be familiar with how the Bundle.require command works and what gem groups are.

TL;DR

  • Set the environment variable DEVELOPER in e.g. your .bashrc with your handle, e.g. anna
  • Put the following code in your config/application.rb Bundler.require(*Rails.groups(ENV['DEVELOPER'] => %w(development)))
  • Add a gem group with yout DEVELOPER-handle, e.g. anna

Description

Each developer in our team wants a different set of gems included/excluded in his local rails development environment. To achieve this each developers sets an ENV['DEVELOPER'] and we extended Rails the config/application.rb to require a custom gem group depending on the current ENV[DEVELOPER]. The code looks like this:

Bundler.require(*Rails.groups(ENV['DEVELOPER'] => %w(development)))

The original file config/application.rb

This way each developer can configure different gems to be loaded in her local dev environment. The Gemfile has the following additional gem group declarations.

group :bob, :anna do
  gem 'wirble'
  gem 'better_errors'
end

group :bob do
    gem 'foo'
end

Bob gets wirble, better_error and foo while anna just loads wirble and better_errors.