Skip to content

Instantly share code, notes, and snippets.

@kylebragger
Forked from mrrooijen/force-ssl.rb
Created November 10, 2011 06:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kylebragger/1354223 to your computer and use it in GitHub Desktop.
Save kylebragger/1354223 to your computer and use it in GitHub Desktop.
Secure with SSL (Subdomain and Protocol) in Rails 3.1
class ApplicationController < ActionController::Base
protect_from_forgery
before_filter :secure_with_ssl
private
def secure_with_ssl
if request.subdomain != 'secure' or request.protocol != 'https'
redirect_to :subdomain => 'secure', :protocol => 'https'
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment