I\'m moving an app to heroku and am having some issues with ssl and redirects.
I\'m on rails 3.1 and I\'ve tried forcing ssl with middleware in the environments producti
Here is how I solved the problem. I removed config.force_ssl = true
from production.rb
and instead used:
Add this method to ApplicationController
def force_ssl
if Rails.env.production?
redirect_to :protocol => 'https' unless request.ssl?
end
end
And add it as a before filter on ApplicationController
before_filter :force_ssl
I am also using a ensure_domain
which switches from http://example.com to http://www.example.com. Make sure such a before filter is called before force_ssl
.