Ruby:Gemfile 中的“要求:假"是什么意思? [英] Ruby: What does 'require: false' in Gemfile mean?

查看:21
本文介绍了Ruby:Gemfile 中的“要求:假"是什么意思?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这样做:

gem 'whenever', require: false

表示需要安装gem,还是不需要安装?

mean that the gem needs to be installed, or does it mean it is not required?

推荐答案

这意味着安装 gem,但不要在启动 Bundler 时调用 require.所以你需要手动调用

This means install the gem, but do not call require when you start Bundler. So you will need to manually call

require "whenever"

如果你想使用图书馆.

如果你愿意

gem "whenever", require: "whereever"

然后 bundler 会下载命名的 gem,但会调用

then bundler would download the gem named whenever, but would call

require "whereever"

这通常用于需要的库名称与 gem 名称不同的情况.

This is often used if the name of library to require is different than the name of the gem.

这篇关于Ruby:Gemfile 中的“要求:假"是什么意思?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆