Prev | Current Page 128 | Next

Brad Ediger

"Advanced Rails"

load_paths contains the lib directories of all
loaded plugins, so the act of mentioning AccountLocation searches for account_
location.rb among those lib directories. Because of this, you do not need to require
anything in order to use the plugin??”just drop the code into vendor/plugins.
SSL Requirement
The ssl_requirement plugin allows you to specify certain actions that must be protected
by SSL. This plugin conceptually divides actions into three categories:
SSL Required
All requests to this action must be protected by SSL. If this action is requested
without SSL, it will be redirected to use SSL. Actions of this type are specified
with the ssl_required class method.
SSL Allowed
SSL is allowed on this action but not required. Actions of this type are specified
by the ssl_allowed class method.
SSL Prohibited
SSL is not allowed for this action. If an action is not marked with ssl_required or
ssl_allowed, SSL requests to that action will be redirected to the non-SSL URL.
In typical Rails fashion, the methods that specify SSL requirements are a declarative
language. They specify what the requirements are, not how to enforce them. This
means that the code reads very cleanly:
class OrderController < ApplicationController
ssl_required :checkout, :payment
ssl_allowed :cart
end
Like the account_location plugin, the ssl_requirement plugin is enabled by including
a module.


Pages:
116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140