How to check in development or production in ERB file in Rails?

at. picture at. · Sep 28, 2012 · Viewed 13.3k times · Source

I want to load jQuery UI via Google CDN if in production and locally if in development. So in my application.html.erb layout, I've got to know whether I'm in production or dev. Is there a variable I can check?

Answer

Zajn picture Zajn · Sep 28, 2012

To expand a bit on Paritosh's answer, Rails.env.production? and Rails.env.development? will return true/false depending on which environment you're using.

These methods are defined in the StringInquirer class in the ActiveSupport module. See them here.