“undefined method” when calling helper method from controller in Rails

后端 未结 11 2085
傲寒
傲寒 2020-12-12 22:36

Does anyone know why I get

undefined method `my_method\' for #

when I call my_method(\"string\") from withi

11条回答
  •  情话喂你
    2020-12-12 22:49

    helpers are for views, but adding a line of code to include that helper file in ApplicationController.rb can take care of your problem. in your case, insert the following line in ApplicationController.rb:

    include ApplicationHelper
    

提交回复
热议问题