I remember seeing this somewhere online but I know have trouble finding information about it. In Rails 3.1, I have a method at the beginning of a session controller, force_ssl, I only want it called in a production environment, how do I do that?
To clarify, the code looks something like this
class SessionsController < ApplicationController
force_ssl
end
Rails.env.production?returns true if the current environment is ‘production’. More generally,Rails.env.somestring?returns true ifRails.env == "somestring". From there you should be good.** EDIT **
Well actually, there’s an easier way to use ssl only in production. Check out this article