João Mateus João Mateus - 28 days ago 8
Ruby Question

Conditional statement to check Rails environment

I have two environments on my rails app: development and production.

I would like to add a conditional statement to a specific controller to check which environment the app is running in order to behave differently.

How can I do this? many thanks in advance.

Answer

You can use Rails.env

Rails.env.development?

Rails.env.production?

This will return boolean value true or false