This project is archived and is in readonly mode.

#5848 ✓invalid
inetufo

“undefined method” when calling helper method in ApplicationHelper module from controller in Rails3 app

Reported by inetufo | October 20th, 2010 @ 03:07 PM

I define a method in ApplicationHelper module

module ApplicationHelper

def mymethod

end

end

class MyController < ApplicationController
def show

   mymethod

end end

When i call it from my controller, just get the "undefined method" message.

Comments and changes to this ticket

  • Luis Hurtado

    Luis Hurtado October 20th, 2010 @ 05:32 PM

    Are helper methods intended to be used in controllers?
    I think helper methods MUST to be used only in views.

  • Aditya Sanghi

    Aditya Sanghi October 20th, 2010 @ 08:49 PM

    • State changed from “new” to “invalid”
    • Importance changed from “” to “Low”

    Yes, helpers are meant to be used in Views not Controllers. If you want to use them in Controllers you can try to access them as @template.mymethod but i'm not it's a documented public way of doing it. There maybe other workaround to access them in controllers, feel free to investigate.

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

<h2 style="font-size: 14px">Tickets have moved to Github</h2>

The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>

People watching this ticket

Pages