简体   繁体   English

Rails 2 — 根据环境加载 Gem

[英]Rails 2 — Load Gems based on the environment

Like rails 3, do we have a functionality of loading specific gems according to the application environment.和 rails 3 一样,我们是否有根据应用环境加载特定 gem 的功能。

rails 3 example导轨 3 示例

group :production do
  gem "activemerchant"
end

do we have anything similar to the above code in rails2我们在 rails2 中是否有类似上述代码的内容

Thanks in Advance.提前致谢。

Define the gems in the appropriate environment files.在适当的环境文件中定义 gem。

So instead of having them all defined in environment.rb , define the ones you want in development.rb and production.rb etc.因此,不要将它们全部定义在environment.rb中,而是在development.rbproduction.rb等中定义你想要的。

# development.rb
config.gem 'sqlite3'

# production.rb
config.gem 'mysql'

if you don't want to use different files for different environments then you can use:如果您不想为不同的环境使用不同的文件,那么您可以使用:

if Rails.env.production?
   config.gem 'activemerchant'
end

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM