What does the nil mean in this gemfile entry?
gem "hub", ">= 1.10.2", :require => nil
I found this question and answer for false;
Bundler: What does :require => false in a Gemfile mean?
In this context, does nil behave the same as false?
What does the nil mean in this gemfile entry?
gem "hub", ">= 1.10.2", :require => nil
I found this question and answer for false;
Bundler: What does :require => false in a Gemfile mean?
In this context, does nil behave the same as false?
Require
nil
orfalse
means that bundler will not load (require
) the specific gems. However, they will be in the$:
load paths, so you can require them explicitly any time you want to use them. It is a good practice to use this, for gems that are only needed in special cases (e.g. external scripts, rake tasks etc.).Yes,
nil
andfalse
behave the same here: it makes Bundler not require the specified gem.Whenever you specify a Gem in your
Gemfile
and runbundle install
, bundler will go and install specified gem and load code for that Gem in you app by puttingrequire 'whenever'
,this way bundler will load code for all of your Gems in your Rails app, and you can call any method from any Gem without any pain,like you do most of the time.but Gems like
whenever,faker or capistrano
are something which you do not need in your app code you need whenever code in yourschedule.rb
file to manage crons and capistrano code indeploy.rb
file to customize deployment recipe so you need not to load code for these gems in your app code and wherever you want to call any method from these Gems you can manually require thsese gems by yourself by puttingrequire "whenever"
. so you put:require => false
or:require => nil
in your Gemfile(both means the same) for these Gems, this way bundler will install that Gem but not load code for that Gem itself, you can do it whenever you want by simply putting like require 'whenever' in your case.