Permalink
Browse files

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>
  • Loading branch information...
1 parent dd74d39 commit b2358827ee76a9e8b003acc992c56a524e915840 @yeban yeban committed with rkh Dec 31, 2011
Showing with 16 additions and 0 deletions.
  1. +16 −0 README.rdoc
View
@@ -801,6 +801,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

0 comments on commit b235882

Please sign in to comment.