我有一个CopiesHelper
模块,其方法为cc
。
在我的ApplicationController
中,我有
helper :all
helper_method :cc #just tried putting this in recently
如果在我的另一个控制器中,我尝试使用cc
方法,我得到
undefined method 'cc' for #<OtherController:0xblublublublub>
我在这里错过了一步吗?
答案 0 :(得分:0)
好吧,似乎助手通常不会在控制器中使用!
答案 1 :(得分:0)
如果您想在您的某个控制器中使用CopiesHelper
,只需执行以下操作:
class YourController < ApplicationController
include CopiesHelper
如果您想在应用的每个控制器中使用CopiesHelper
,请执行以下操作:
class ApplicationController < ActionController::Base
include CopiesHelper