ktulasi
Joined: 21 Oct 2009 Posts: 55
|
Posted: Thu Dec 10, 2009 12:31 pm Post subject: About helper methods in rails |
|
|
Rails frame work provides large number of Helpers.These Helpers are availalable to all templates by default.
When a controller is generated with that it defaultly generates helpers of the particular controller with name as controllers.
Public Instance methods for helpers are:
helper(*args,&block)
helper_attr
helper_method
helpers
helper(*args , &block):
---------------------------
*args : one or more modules,symbols or special symbols.
&block : a block defining block methods.
When the argument is string or symbol the method will provide the "_helper"suffix,require the file and include the module in the template class.
helper :foo ---> requires the foo_helper and includes FooHelper.
helper ;resources/foo' ---> requires the resources/foo helper and includes 'Resources::FooHelper.
When the argument is a module it can be directly included in the template class.
helper FooHelper -->includes FooHelper
When argument is a symbol :all the controller will include all helpers.
helper :all
helper_attr(*attrs)
------------------------
Declares accessors for controller attributes.
ex: helper_attr :name
helper_method(*methods)
--------------------------------
Declare a controller method as a helper
helpers()
----------
Provides a proxy to access helpers methods from outside the view. |
|