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:
parent
5eb65ef9b0
commit
7abe19cc59
16
README.rdoc
16
README.rdoc
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue