method

env

v2.2.1 - Show latest stable - Class: Rails
env()
public

No documentation available.

# File railties/lib/initializer.rb, line 51
    def env
      @_env ||= begin
        require 'active_support/string_inquirer'
        ActiveSupport::StringInquirer.new(RAILS_ENV)
      end
    end

2Notes

Pretty way to test for current environment

bquorning · Jan 16, 20108 thanks

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?

Used to get current Rails environment

arronwashington · Jul 4, 20085 thanks

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

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