I'm confused by the rails documentation that I'm reading here. In particular, this sentence:
By default, each controller will include all helpers. These helpers are only accessible on the controller through
.helpers
What is this .helpers
that it is referring to? I have a helper defined in app/helpers/areas_helper.rb
:
module AreasHelper
def my_helper
puts "Test from helper"
end
end
I would like to use this helper in app/controllers/locations_controller.rb
:
class LocationsController < ApplicationController
def show
helpers.my_helper
end
end
However, I get a method undefined error. How is this .helpers
supposed to be used?
I know there are other ways to get access to helpers in controllers, but I'm specifically asking about this piece of documentation and what it's trying to say.
.helpers
is the inbuilt Rails helpers, such asredirect_to
etc – Richard Peck.helpers
come into play when using a built in Rails helper likeredirect_to
? – flyingL123.helpers
I am looking at it – Richard Peck