There is a well-known idiom in Rails, to tell wheather one is runnign in a specifc environment or not:

Rails.env.production? # => false
Rails.env.development? # => true

At first, it looks like Rails.env is a special kind of object that has methods defined on it to check for the environment properties. However, upon closer inspection, it looks like it is really just a String, but not quite:

>> Rails.env
=> "development"
>> Rails.env.class
=> ActiveSupport::StringInquirer

As the documentation says, StringInquirer is just a pretty way to test for equality. It can be used outside of Rails, say for example to be a bit lenient when reading environment variables:

require 'active_support/core_ext/string'

class Logger
  def log(message)
    message if verbose?


  def verbose?
    env_verbose.true? || env_verbose.yes?

  def env_verbose
    @env_verbose ||= (ENV['VERBOSE'] ||= '').downcase.inquiry
end"Hello, World") # => nil

ENV['VERBOSE'] = 'yes'"Hello, World") # => "Hello, World"

ENV['VERBOSE'] = 'YES'"Hello, World") # => "Hello, World"

ENV['VERBOSE'] = 'True'"Hello, World") # => "Hello, World"