How to tell if rails is in production?

sent-hil picture sent-hil · Dec 28, 2009 · Viewed 59.7k times · Source

I used script/server -e production to start rails in production mode. It did and I got no errors. However how do I tell if it is in production mode? I tried a non-existent route, and I got a similar error page I did in development.

I thought if under production model, I get the 404 error page that is in my /public folder.

Does it mean it didn't start in production mode?

Thanks for your help.

Answer

Krishnaprasad Varma picture Krishnaprasad Varma · Aug 22, 2011

If its Rails 3.1+, Rails.env.production? will return true when in production.

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