Created
June 16, 2011 20:30
-
-
Save jmccartie/1030191 to your computer and use it in GitHub Desktop.
Force / unforce SSL based on given hash of pages you with to protect
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def force_ssl | |
pages = {"giving" => ["login", "give"]} | |
pages.each do |controller, actions| | |
if params[:controller] == controller && actions.include?(params[:action]) | |
if !request.ssl? && !Rails.env.development? | |
redirect_to :protocol => 'https://', :status => :moved_permanently | |
end | |
elsif request.ssl? | |
redirect_to :protocol => 'http://', :status => :moved_permanently | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment