Rails: Different Code according to the Environment


The code executes different method according to the environment, in Rails. In this way, you can show message only in development environment.

Judge Environment

Rails.env.development?, Rails.env.production? returns true/false.

What is Rails.env?

Rails.env is not String, it is ActiveSupport::StringInquirer extending String. StringInquirer is used as follows.

Then, how StringInquirer is implemented?

Here is ActiveSupport::StringInquirer in master branch on .

It can use all methods String has.