[英]How do you gain access to the helper methods inside the controller with Rails
我想在我的 controller 中使用我的助手中的方法。 我不知道如何使用我聽說的 view_context 可以解決問題
正如 apneadiving 所說,將其設為 controller 方法並將其設為輔助方法。
application_controller.rb
helper_method :do_stuff
def do_stuff
#this method is available in all controllers and views
我投票支持@apneadiving 的想法。 但這里有:
class SomeController < ApplicationController
include SomeHelper
end
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.