Search code examples
ruby-on-railsruby-on-rails-3ruby-on-rails-3.2development-environmentproduction-environment

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


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?


Solution

  • 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.