Methods
F
Instance Public methods
force_ssl(options = {})

Force the request to this particular controller or specified actions to be under HTTPS protocol.

Note that this method will not be effective on development environment.

Options

  • only - The callback should be run only for this action
  • except - The callback should be run for all actions except this action
    # File actionpack/lib/action_controller/metal/force_ssl.rb, line 26
26:       def force_ssl(options = {})
27:         host = options.delete(:host)
28:         before_filter(options) do
29:           if !request.ssl? && !Rails.env.development?
30:             redirect_options = {:protocol => 'https://', :status => :moved_permanently}
31:             redirect_options.merge!(:host => host) if host
32:             redirect_options.merge!(:params => request.query_parameters)
33:             redirect_to redirect_options
34:           end
35:         end
36:       end