env() public

Returns the current Rails environment.

Rails.env # => "development" Rails.env.development? # => true Rails.env.production? # => false
Show source
Register or log in to add new notes.
January 16, 2010 - (>= v2.2.1)
8 thanks

Pretty way to test for current environment

You can check your current Rails environment using nice methods such as:

Rails.env.development? Rails.env.test? Rails.env.production? Rails.env.your_custom_environment? 
July 4, 2008
5 thanks

Used to get current Rails environment

Rails#env returns a string representing the current Rails environment.

Code example

>> Rails.env # in development mode Rails.env => "development"