[Ruby on Rails] Determine production/development Environment with Rails.env
In Ruby on Rails, determining environments like production/development is done with Rails.env.
if Rails.env == 'production'
// production
elsif Rails.env == 'staging'
// staging
elsif Rails.env == 'development'
// development
elsif Rails.env == 'test'
// test
end
You can also write it this way.
puts "Rails.env is production" if Rails.env.production?
That’s all from the Gemba.