我有一个 CopiesHelper
模块与方法 cc
.
在我 ApplicationController
我有
helper :all
helper_method :cc #just tried putting this in recently
如果在我的另一个控制器中,我尝试使用 cc
方法,我得到
undefined method 'cc' for #<OtherController:0xblublublublub>
我是不是漏掉了一个步骤?
如果你想使用你的 CopiesHelper
在你的一个控制器中,只需做:
在 {app_dir}appcontrollersyour_controller.rb)。
class YourController < ApplicationController
include CopiesHelper
如果你想使用你的 CopiesHelper
在你的应用程序的每个控制器中,只需做:
在 {app_dir}appcontrollersapplication_controller.rb
class ApplicationController < ActionController::Base
include CopiesHelper
好吧,看来在控制器中一般不使用助记符了!