Created
December 21, 2008 02:37
-
-
Save christianromney/38516 to your computer and use it in GitHub Desktop.
Forcing Rails to Think a Request is Using SSL
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
# app/controllers/application.rb | |
class ApplicationController < ActionController::Base | |
before_filter :modify_protocol | |
private | |
def modify_protocol | |
returning(true) do | |
if Rails.configuration.protocol_modifier | |
request.extend(Rails.configuration.protocol_modifier) | |
end | |
end | |
end | |
end |
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
# lib/duplicity/force_ssl.rb | |
module Duplicity | |
module ForceSSL | |
def protocol | |
'https://' | |
end | |
end | |
end |
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
# config/environment.rb | |
module CustomConfiguration | |
attr_accessor :protocol_modifier | |
end | |
Rails::Initializer.run do |config| | |
config.extend(CustomConfiguration) | |
# standard configuration elided for clarity | |
end |
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
# config/environments/production.rb | |
config.protocol_modifier = Duplicity::ForceSSL |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment