Forum: Ruby on Rails How to include a helper method in a controller

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Tom H. (Guest)
on 2009-04-22 20:04
Hi there,

why do I get the error...

undefined method `format_phone_number_for' for

... in this situation:


class User::MailingsController < ApplicationController
  def whatever
    [...] format_phone_number_for(@somebody)     # <- why is this
"undefined" ?


module PhonenumberHelper
  def format_phone_number_for(parent)

And what do I have to do to have this method available in this
(I have already tried by including "helper PhonenumberHelper" in the

Thanks for your help!
Sijo k. (Guest)
on 2009-04-23 09:55
Did you try like
include PhonenumberHelper
      in mailings_controller.rb  and
is phonenumber_helper.rb in app/helpers?

bushfreakz (Guest)
on 2009-04-23 11:08
(Received via mailing list)
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
Tom H. (Guest)
on 2009-04-23 14:04
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.
This topic is locked and can not be replied to.