public
Description: Phusion Passenger (mod_rails)
Homepage: http://www.modrails.com/
Clone URL: git://github.com/FooBarWidget/passenger.git
Search Repo:
Click here to lend your support to: passenger and make a donation at www.pledgie.com !
Respect setting ENV['RAILS_ENV'] in environment.rb. Fixes issue #6.
Hongli Lai (Phusion) (author)
Wed Apr 23 04:05:28 -0700 2008
commit  5bc9ea518e346767e4b69d70044c3dac90bda113
tree    50e3875d3ca7d7a6101d759ada24d787825c44a8
parent  2cbd4debcb83c562a454e239a9b65ad3c19e2bba
...
233
234
235
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
236
237
238
...
246
247
248
249
250
 
 
 
 
251
252
253
...
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
...
261
262
263
 
 
264
265
266
267
268
269
270
0
@@ -233,6 +233,21 @@
0
     Object.const_set(:RAILS_ROOT, @app_root)
0
     if defined?(Rails::Initializer)
0
       Rails::Initializer.run(:set_load_path)
0
+
0
+ # The Rails framework is loaded at the moment.
0
+ # environment.rb may set ENV['RAILS_ENV']. So we re-initialize
0
+ # RAILS_ENV in Rails::Initializer.load_environment.
0
+ Rails::Initializer.class_eval do
0
+ def load_environment_with_passenger
0
+ if defined?(::RAILS_ENV)
0
+ Object.send(:remove_const, :RAILS_ENV)
0
+ end
0
+ Object.const_set(:RAILS_ENV, (ENV['RAILS_ENV'] || 'development').dup)
0
+ load_environment_without_passenger
0
+ end
0
+
0
+ alias_method_chain :load_environment, :passenger
0
+ end
0
     end
0
     require 'config/environment'
0
     if ActionController::Base.page_cache_directory.blank?
0
@@ -246,8 +261,10 @@
0
       require 'dispatcher'
0
     end
0
     require_dependency 'application'
0
- Dir.glob('app/{models,controllers,helpers}/*.rb').each do |file|
0
- require_dependency normalize_path(file)
0
+ if GC.copy_on_write_friendly?
0
+ Dir.glob('app/{models,controllers,helpers}/*.rb').each do |file|
0
+ require_dependency normalize_path(file)
0
+ end
0
     end
0
   end
0
 
...
6
7
8
 
 
9
10
11
...
6
7
8
9
10
11
12
13
0
@@ -6,6 +6,8 @@
0
 require 'spawner_error_handling_spec'
0
 include Passenger
0
 
0
+# TODO: write unit test which checks whether setting ENV['RAILS_ENV'] in environment.rb is respected (issue #6)
0
+
0
 describe ApplicationSpawner do
0
   before :all do
0
     ENV['RAILS_ENV'] = 'production'

Comments

    No one has commented yet.