When do you need a require in a rails Gemfile?

后端 未结 4 1279
野趣味
野趣味 2020-12-20 15:49

In my gemfile I have things like:

gem \'net-sftp\', \'2.1.1\', :require => \'net/sftp\'
gem \'backup\', \'3.0.27\'
gem \'watu_table_builder\', :require =&         


        
4条回答
  •  一生所求
    2020-12-20 16:18

    You need a :require if the name of the file that's required to activate the gem can't be inferred from the gem's name. Ruby convention is to name your gem the same thing as the "require" statement you should use, but not everything follows the convention.

    :require => false disables automatic requiring by Bundler, so you'd need to use require 'foo' manually to use the code in foo. This is mainly useful if a gem is large or expensive to activate and only used in certain cases.

提交回复
热议问题