public
Description: Ruby on Rails
Homepage: http://rubyonrails.org
Clone URL: git://github.com/rails/rails.git
Add Rails.logger, Rails.root, Rails.env and Rails.cache shortcuts for RAILS_* 
constants


git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@9180 
5ecf4fe2-1ee6-0310-87b1-e25e094e27de
lifo (author)
Mon Mar 31 19:09:52 -0700 2008
commit  dc1166d12bbe4f5b65862f4d46cd0ab98141b1cb
tree    e71f9a8a7174177ca439f3e09c0669e7f677a034
parent  c2ea2874475f4f93fe087ef63cdeee020dc98cdd
...
1
2
 
 
3
4
5
...
1
2
3
4
5
6
7
0
@@ -1,5 +1,7 @@
0
 *SVN*
0
 
0
+* Add Rails.logger, Rails.root, Rails.env and Rails.cache shortcuts for RAILS_* constants [pratik]
0
+
0
 * Allow files in plugins to be reloaded like the rest of the application.  [rick]
0
 
0
   Enables or disables plugin reloading.
...
22
23
24
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
25
26
27
...
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
0
@@ -22,6 +22,22 @@ module Rails
0
     @@configuration = configuration
0
   end
0
   
0
+  def self.logger
0
+    RAILS_DEFAULT_LOGGER
0
+  end
0
+  
0
+  def self.root
0
+    RAILS_ROOT
0
+  end
0
+  
1
+  def self.env
0
+    RAILS_ENV
0
+  end
0
+  
0
+  def self.cache
0
+    RAILS_CACHE
0
+  end
0
+  
0
   # The Initializer is responsible for processing the Rails configuration, such
0
   # as setting the $LOAD_PATH, requiring the right frameworks, initializing
0
   # logging, and more. It can be run either as a single command that'll just

Comments

yizzreel Sun May 11 15:55:42 -0700 2008 at railties/lib/initializer.rb L33

A method like Rails.env?(“environment”) or Rails.production? to ask for current environment could be very helpful too.