I have an HTTP and HTTPS version of my Ruby on Rails running, and if someone accesses through the HTTP one, I want to automatically reload the HTTPS version.
I have done this before on Apache with .httaccess. How can I do it on Rails?
Thanks
I have an HTTP and HTTPS version of my Ruby on Rails running, and if someone accesses through the HTTP one, I want to automatically reload the HTTPS version.
I have done this before on Apache with .httaccess. How can I do it on Rails?
Thanks
In your production.rb file (or whichever env you are forcing ssl) add
config.force_ssl = true
You can also achieve that by:
class ApplicationController < ActionController::Base
force_ssl if: :ssl_enabled?
private
def ssl_enabled?
%w(staging production).include?(Rails.env)
end
end