Helpers are simple modules that can be used in controllers to prevent developers
from having to write the same code over and over again. There's no actual
definition of how helpers should be used and what they should do but the general
idea is quite simple, all logic that may be shared among controllers should go
in a helper. For example, Ramaze ships with it's own layout helper that adds a
set_layout() (see the Views chapter).
In order to use a helper there are a few guidelines it should follow. The most important guideline (or rule) is that it should be declared under the Ramaze::Helper namespace. Say your helper is called "Cake" this would result in Ramaze::Helper::Cake as the full name. The second rule/guideline is that helpers should be placed in the "helper" directory of your Ramaze application (or any other directory added to the list of helper paths). This is required in order to load helpers the ramaze way, otherwise you'll have to manually load each helper.
Loading helpers the Ramaze way is pretty easy and can be done using the method helper():
class Blogs < Ramaze::Controller helper :cake end
This method can load multiple helpers in a single call as well:
class Blogs < Ramaze::Controller helper :cake, :pie, :candy end
If you have your helper located somewhere else or don't want to use the helper() method you can just include each helper the regular way:
class Blogs < Ramaze::Controller include Ramaze::Helper::Cake include Ramaze::Helper::Pie include Ramaze::Helper::Candy end
As you can see this requires more lines of code and thus it's recommended to load all helpers the Ramaze way.
- : basic authentication without a model.
- : basic benchmarking of your code.
- : makes building forms fun again.
- : caching of entire actions and custom values in your controllers.
- : protect your controllers from CSRF attacks.
- : quick and easy way to send Emails.
- : helper for .
- : easily generate Gravatars.
- : helper for OpenID authentication.
- : easily set layouts for specific actions.
- : easily paginate rows of data.
- : captches using simple mathematical questions.
- : uploading files made easy.
- : authenticate users using a model.
Note that you may also find some popular helpers, that are used by default in Ramaze, under the Innate project.
- : provides before/after wrappers for actions.
- : gives shortcuts to some CGI methods.
- : gives simple access to session.flash.
- : provides the path to a given Node and action.
- : provides the request redirect, raw_redirect and respond convenience methods.
- : provides variants for partial, custom, full view rendering.