为什么人们将诸如“gem ‘guard’’之类的东西放在 Gemfiles 的‘:development’组中
从这个角度看:
Bundler.require *Rails.groups(:assets => %w(development test))
应用程序启动时需要这些获取组:
[:default, :development, :assets]
为什么应用程序中需要 guard
?
有最佳实践吗?例如:
group :misc do
gem "guard"
end
From the look of this:
Bundler.require *Rails.groups(:assets => %w(development test))
These get groups get required when the app launches:
[:default, :development, :assets]
Why should guard
get required in your app?
Is there a best practice? e.g.:
group :misc do
gem "guard"
end
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Bundler 足够智能,只需要当前环境的 gem。这些组对应于这些环境。如果您的应用程序在开发环境中运行,Bundler 需要该组中的 gem,但不需要测试组中的 gem,依此类推。
人们经常将 gem 放入他们的开发环境中需要/想要的 :development 组中,而不是放在他们的生产系统中。
该行
只是表示 Bundler 仅在您的开发和测试环境中需要资产组中的 gem。这可以阻止您的资产在生产服务器上进行延迟编译,您通常希望在生产服务器上部署预编译资产。
Bundler is intelligent enough to only require gems for the current environment. The groups correspond to these environments. If your app is running in the development environment, Bundler requires the gems from that group, but not those from the test group, and so on.
People often put gems in the :development group that they need/want for their dev environment, but not on their production system.
The line
simply says that Bundler will require the gems from the assets group only for your development and test environment. This stops your assets from being lazily compiled on your production server, where you usually want to deploy precompiled assets.