Rohit
Rohit

Reputation: 5721

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 example

group :production do
  gem "activemerchant"
end

do we have anything similar to the above code in rails2

Thanks in Advance.

Upvotes: 2

Views: 762

Answers (2)

Ireneusz Skrobis
Ireneusz Skrobis

Reputation: 1533

if you don't want to use different files for different environments then you can use:

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

Upvotes: 0

Douglas F Shearer
Douglas F Shearer

Reputation: 26488

Define the gems in the appropriate environment files.

So instead of having them all defined in environment.rb, define the ones you want in development.rb and production.rb etc.

# development.rb
config.gem 'sqlite3'

# production.rb
config.gem 'mysql'

Upvotes: 1

Related Questions