NoMethodError when trying to invoke helper method from Rails controller

前端 未结 14 1193
滥情空心
滥情空心 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:49

    helper :all makes all the helpers (yes, all of them) available in the views, it does not include them into the controller.

    If you wish to share some code between helper and controller, which is not very desirable because helper is UI code and controller is, well, controller code, you can either include the helper in the controller, or create a separate module and include that in the controller and the helper as well.

提交回复
热议问题