如何在模型中使用ApplicationViewHelper的方法

时间:2014-04-15 14:58:25

标签: ruby-on-rails model view-helpers

我在文件app/helpers/application_view_helper.rb中有一个方法:

module ApplicationViewHelper
...
  def cache_key_with_permission_for_all model
  ...
  end
end

我尝试从模型中访问它:

class Classification < ActiveRecord::Base
...
  def self.get_current_cache_key
    "index-#{ActionController::Base.helpers.cache_key_with_permission_for_all Classification}"
  end
end

但我收到错误:

NoMethodError - undefined method `cache_key_with_permission_for_all' for #<ActionView::Base:0x00000004e3ac70>:
  app/models/classification.rb:140:in `get_current_cache_key'

我错了什么?

0 个答案:

没有答案