Skip to content

Instantly share code, notes, and snippets.

@vishnugopal
Created September 17, 2012 17:34
Show Gist options
  • Save vishnugopal/3738667 to your computer and use it in GitHub Desktop.
Save vishnugopal/3738667 to your computer and use it in GitHub Desktop.
Force SSL for a particular action
class SessionController
before_filter :force_ssl, :only => :create
# login
def new
end
# login
def create
end
private
def force_ssl
if !request.ssl?
redirect_to :protocol => 'https'
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment