Hi there,
why do I get the error…
undefined method `format_phone_number_for’ for
#User::MailingsController:0xb70aae58
… in this situation:
controllers/user/mailings_controller.rb:
class User::MailingsController < ApplicationController
def whatever
[…]
[…] format_phone_number_for(@somebody) # <- why is this
“undefined” ?
[…]
end
end
helpers/phonenumber_helper.rb:
module PhonenumberHelper
def format_phone_number_for(parent)
[…]
end
end
And what do I have to do to have this method available in this
controller?
(I have already tried by including “helper PhonenumberHelper” in the
controller)
Thanks for your help!
Tom
Did you try like
include PhonenumberHelper
in mailings_controller.rb and
is phonenumber_helper.rb in app/helpers?
Sijo
Thanks for your replies!
@ Sijo:
The problem was resolved by adding “include PhonenumberHelper” in the
controller, as you have suggested (I was sure I had done that before…)
@ bushfreakz:
Any helpers in app/helpers are only available to views, by default. If
you have “helper :all” in ApplicationController, all helpers in
app/helpers are available to all views only.
hello im very new to rails but i “think”
it should go in the mailings_helper instead of the phonenumber_helper
or there should be an application_helper which i think is universal