NoMethodError when trying to invoke helper method from Rails controller

前端 未结 14 1047
滥情空心
滥情空心 2020-11-30 20:05

I\'m getting a NoMethodError when trying to access a method defined in one of my helper modules from one of my controller classes. My Rails application uses the

相关标签:
14条回答
  • 2020-11-30 20:59

    Any helper can be accessed using @template variable in the controller.

    @template.my_super_helper

    0 讨论(0)
  • 2020-11-30 21:02

    It is probably cleaner to use the helpers method:

    class FooController < ActionController::Base
      def action
        self.class.helpers.helper_method arg
      end
    end
    
    0 讨论(0)
提交回复
热议问题