Ruby on Rails 3 - 模型中包含的帮助程序方法产生"undefined local variable or method `config' for"错误



我有一个非常复杂的helper方法,它也需要在模型中。我只在模型中包含了一些助手,但同样的方法在Rails3.0.7上不起作用。

module ContentsHelper
  def content_teaser record
    # it uses image_tag, truncate, raw, and some others.
  end
end
class Content < ActiveRecord::Base
  include ActionView::Helpers::TagHelper
  include ActionView::Helpers::UrlHelper
  include ActionController::UrlFor
  include ActionView::Helpers::TextHelper
  include ActionView::Helpers::RawOutputHelper
  include ActionView::Helpers::AssetTagHelper
  include ContentsHelper
  include Rails.application.routes.url_helpers
  def teaser
    content_teaser self.body        
  end
end

错误信息我有

undefined local variable or method `config' for #<Content:0x10bac7248>
app/helpers/contents_helper.rb:8:in `content_teaser'
app/models/content.rb:70:in `teaser'

有什么建议吗?

我在使用Rails 3.1 RC 时也遇到了错误

NameError:
   undefined local variable or method `config'

一些Rails源代码跟踪和我发现的缺失包括ActionView::AssetPaths。

include ActionView::AssetPaths
include ActionView::Helpers::AssetTagHelper

相关内容

  • 没有找到相关文章

最新更新