module AbstractController::Helpers::ClassMethods
def helper(*args, &block)
end
end
"wadus"
def wadus
helper FooHelper, "woo", "bar/baz" do
Furthermore, all the above styles can be mixed together:
end
end
"wadus"
def wadus
helper do
+wadus+ method available in templates of the enclosing controller:
the context of the controller helper module. This simple call makes the
The method accepts a block too. If present, the block is evaluated in
The last two assume that "foo/bar".camelize returns "Foo::Bar".
helper :"foo/bar"
helper "foo/bar"
helper :"Foo::Bar"
helper "Foo::Bar"
# String/symbol without the "helper" suffix, camel or snake case.
helper Foo::BarHelper
# Module, recommended.
Namespaces are supported. The following calls include +Foo::BarHelper+:
yet loaded, it has to be autoloadable, which is normally the case.
object using String#constantize. Therefore, if the module has not been
When strings or symbols are passed, the method finds the actual module
The last two assume that "foo".camelize returns "Foo".
helper :foo
helper "foo"
helper :Foo
helper "Foo"
# String/symbol without the "helper" suffix, camel or snake case.
helper FooHelper
# Module, recommended.
include +FooHelper+:
Modules can be specified in different ways. All of the following calls
Includes the given modules in the template class.
def helper(*args, &block) modules_for_helpers(args).each do |mod| next if _helpers.include?(mod) _helpers_for_modification.include(mod) end _helpers_for_modification.module_eval(&block) if block_given? end