module ActionController::ForceSSL::ClassMethods - actionpack-3.2.22 Documentation

# module ActionController::ForceSSL::ClassMethods

### Public Instance Methods

force_ssl(options = {}) click to toggle source

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 lib/action_controller/metal/force_ssl.rb, line 26
    def force_ssl(options = {})
      host = options.delete(:host)
      before_filter(options) do
        if !request.ssl? && !Rails.env.development?
          redirect_options = {:protocol => 'https://', :status => :moved_permanently}
          redirect_options.merge!(:host => host) if host
          redirect_options.merge!(:params => request.query_parameters)
          redirect_to redirect_options
        end
      end
    end