This project is archived and is in readonly mode.

Added :environment options to config.gem
Reported by José Valim | May 16th, 2008 @ 06:21 PM | in 2.1.1
This way we can specify which gems will be loaded in each environment. This is useful since we don't want ZenTest or ruby-debug running in production.
Usage:
config.gem "ZenTest", :environment => :test
config.gem "ruby-debug", :environment => [:development, :test]
Tests included.
Comments and changes to this ticket
- 
         José Valim May 16th, 2008 @ 06:26 PMOh, if :environment is not sent, like: config.gem "hpricot", :version => '0.6', :source => "http://code.whytheluckystiff.net" We have the default behaviour, i.e. the gem is loaded in all environments. 
- 
         Rick May 16th, 2008 @ 06:48 PM- Milestone set to 2.1.1
- State changed from new to open
- Assigned user set to Rick
 Is there a reason you're using ENV['RAILS_ENV'] and not Rails.environment? 
- 
         José Valim May 16th, 2008 @ 07:02 PMSearching the code I had more results with ENV['RAILS_ENV'], so I've used that one. =) 
- 
         DHH May 18th, 2008 @ 11:38 AM- State changed from open to invalid
 You can just do this in config/environments/test.rb: config.gem "ZenTest" Then it's only loaded in the test environment. 
- 
            
         Josh Goebel February 10th, 2009 @ 05:43 PM- Tag set to patch, railties, tested
 Ok, i'm a bit confused... so I have something like: require 'ruby-debug' (or or could just as easily be other config.gem stuff) in my development.rb, since it isn't needed in production... so I'm setting up a new box and I do: rake gem:install And it blows up... because in production mode cache_classes is enabled... and it tries to load all the models (load_application_classes in init) before it can install the gems... so if I do something like reference a class in a model (such as MiniMagick) then rake dies with an initialized constant error for MiniMagick before the gem installer has a chance to install the gem. Am I missing something here? 
- 
            
         Josh Goebel February 10th, 2009 @ 05:43 PMI should specify I'm really doing: RAILS_ENV="production" rake gem:install gem:install works fine when run in dev mode since cache_classes usually isn't turned on. 
- 
            
         Josh Goebel February 10th, 2009 @ 08:32 PM- Tag changed from patch, railties, tested to 2.2.2, bug
 I'm thinking maybe the global variable that determine if rake gem:install is being run should turn off cache_classes by default? 
- 
            
         Donald Ball August 14th, 2009 @ 03:38 AMI see two advantages to this approach: - 
It's somewhat drier when you have a gem that's used in more than one environment 
- 
DHH's approach requires you to run rake gem:install for each environment to be sure you've got everything; it would be nice to be able to run it once across all environments 
 
- 
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile »
<h2 style="font-size: 14px">Tickets have moved to Github</h2>
The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>
 DHH
      DHH
 Hugo Barauna
      Hugo Barauna
 José Valim
      José Valim
 Josh Goebel
      Josh Goebel
 Rick
      Rick