我想在我的控制器内使用我的帮助器中的方法。 我不知道如何使用我听过的view_context可以做到这一点
答案 0 :(得分:3)
正如apneadiving所说,将其作为一种控制器方法并使其成为一种辅助方法。
application_controller.rb
helper_method :do_stuff
def do_stuff
#this method is available in all controllers and views
答案 1 :(得分:0)
我投票赞成@ apneadiving的想法。但是这里有:
class SomeController < ApplicationController
include SomeHelper
end