Skip to content

Instantly share code, notes, and snippets.

@jfgomez86
Created January 12, 2012 16:43
Show Gist options
  • Select an option

  • Save jfgomez86/1601525 to your computer and use it in GitHub Desktop.

Select an option

Save jfgomez86/1601525 to your computer and use it in GitHub Desktop.
Force SSL
class AccountsController < ApplicationController
before_filter :force_ssl
def new
end
def create
end
end
class ApplicationController < ActionController::Base
private
# Works with Rails 3.1
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