Hello, I’m pulling my hair out as I can’t seem to find resolution to my
simple problem, which is calling methods from controllers to helpers.
in my application_controller.rb I have helper :all, which as i
understand should include all helpers all the time.
Then when i try to call methods in helpers i get undefined method error.
Is there another place where i have to include helpers to make them
available in controllers?
Helper methods are used in the template class (ActionView::Template),
not controllers. If I’m reading the documentation right, putting
“helper :all” in a controller makes all helpers found in app/helpers/
**/*rb available in that controller’s views.
On Oct 31, 3:48 pm, Great J. [email protected]
If you really want to use an existing Rails helper in your
controllers, do the following :
- add the following the following code to your
application_controller (a singleton and a method):
include other helpers
- Use the helpers in your controller : @nice_string =
On Oct 31, 8:48 pm, Great J. [email protected]