README: show how to define helper functions in a separate `module`

Developers might prefer to define helpers in a separate `module`, particularly
for modular apps, so let's provide an example in the docs.

Signed-off-by: Anurag Priyam <anurag08priyam@gmail.com>
This commit is contained in:
Anurag Priyam 2011-12-31 23:32:25 +05:30
parent 5eb65ef9b0
commit 7abe19cc59
1 changed files with 16 additions and 0 deletions

View File

@ -679,6 +679,22 @@ route handlers and templates:
bar(params[:name])
end
Helper methods can be separately defined in a module:
module FooUtils
def bar(name)
"#{name}bar"
end
end
module MooUtils
# ...
end
helpers FooUtils, MooUtils
The effect is same as including a module.
=== Using Sessions
A session is used to keep state during requests. If activated, you have one