Module: ForceHttp::ClassMethods

Defined in:
lib/force_http.rb

Instance Method Summary collapse

Instance Method Details

#force_http(options = {}) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
# File 'lib/force_http.rb', line 10

def force_http(options = {})
  host = options.delete(:host)
  before_filter(options) do
    if request.ssl? && !Rails.env.development?
      redirect_options = {:protocol => 'http://', :status => :moved_permanently}
      redirect_options.merge!(:host => host) if host
      redirect_options.merge!(:params => request.query_parameters)
      redirect_to redirect_options
    end
  end
end