This project is archived and is in readonly mode.
Added :environment options to config.gem
-
José Valim
Oh, 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
- 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
Searching the code I had more results with ENV['RAILS_ENV'], so I've used that one. =)
-
DHH
- 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
- 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
I 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
- 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
I 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
-
