Install

As Gem

As plugin

SSL Requirement

redirect https to http by default

redirect http requests to https with ssl_required

allow https and http with ssl_allowed

Example:

class ApplicationController < ActionController::Base
include SslRequirement
end
class AccountController < ApplicationController
ssl_required :signup, :payment
ssl_allowed :index
def signup
# Non-SSL access will be redirected to SSL
end
def payment
# Non-SSL access will be redirected to SSL
end
def index
# This action will work either with or without SSL
end
def other
# SSL access will be redirected to non-SSL
end
end

You can overwrite the protected method ssl_required? to rely on other things
than just the declarative specification. Say, only premium accounts get SSL.

When including SslRequirement it adds before_filter :ensure_proper_protocol.