没有找到辅助方法

时间:2010-06-07 19:00:14

标签: ruby-on-rails helpers

我有一个CopiesHelper模块,其方法为cc

在我的ApplicationController中,我有

helper :all 
helper_method :cc #just tried putting this in recently

如果在我的另一个控制器中,我尝试使用cc方法,我得到

undefined method 'cc' for #<OtherController:0xblublublublub>

我在这里错过了一步吗?

2 个答案:

答案 0 :(得分:0)

好吧,似乎助手通常不会在控制器中使用!

答案 1 :(得分:0)

如果您想在您的某个控制器中使用CopiesHelper,只需执行以下操作:

{app_dir} /app/controllers/your_controller.rb

class YourController < ApplicationController
    include CopiesHelper

如果您想在应用的每个控制器中使用CopiesHelper,请执行以下操作:

{app_dir} /app/controllers/application_controller.rb

class ApplicationController < ActionController::Base
    include CopiesHelper