Skip to content

Instantly share code, notes, and snippets.

@ungoldman
Created February 21, 2013 21:24
Show Gist options
  • Save ungoldman/5008383 to your computer and use it in GitHub Desktop.
Save ungoldman/5008383 to your computer and use it in GitHub Desktop.
force_ssl replacement method
class ApplicationController < ActionController::Base
[...]
private
def switch_to_https
return if Rails.env.development? ||
request.ssl? ||
request.protocol.include?('https') ||
request.headers['HTTP_X_FORWARDED_PROTO'] == 'HTTPS'
redirect_to({:protocol => 'https://'}.merge(params), :flash => flash)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment