Bundler Require
If you want your ruby project to auto-require gems specified in a group in Gemfile then :
require 'bundler/setup'
Bundler.require(:group)
You won't need to write require for gems then, except for gems like ActiveRecord which are part of larger gems like rails. This is very handy in spec_helper where I just need to say Bundler.require(:default, :test)
If a gem is not found it will ask user to do a bundle install instead of throwing an error on require
Written by Shadab
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Ruby
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#