0

I'm trying to get the current environment I'm working on with rails using ENV['RAILS_ENV'] but it returns nil. Does anyone know why? I get an environment when I run the Rails.env script but I need to use ENV['RAILS_ENV'] in my environment.rb file. Thanks.

4

2 回答 2

0

试试这个(rails 3不确定早期版本)

Rails.env 

或者

ENV['RAILS_ENV'] || "development"
于 2013-06-18T19:38:26.193 回答
0

你可以用

Rails.env.development? || Rails.env.staging? || Rails.evn.test?
于 2013-06-18T19:52:25.510 回答