Module: SecureRoutes::RouteSet

Defined in:
lib/secure_routes/route_set.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object



4
5
6
7
8
# File 'lib/secure_routes/route_set.rb', line 4

def self.included base
  base.class_eval do
    alias_method_chain :url_for, :secure
  end
end

Instance Method Details

#url_for_with_secure(options) ⇒ Object



10
11
12
13
14
15
16
17
# File 'lib/secure_routes/route_set.rb', line 10

def url_for_with_secure options
  if Rails.application.config.action_dispatch.secure_routes
    options[:only_path] = false if (options[:secure] === true && options[:protocol] == 'http://') || (options[:secure] === false && options[:protocol] == 'https://')
    options[:protocol] = 'http://' if options[:secure] === false
    options[:protocol] = 'https://' if options[:secure] === true
  end
  url_for_without_secure options
end