I have a quite complex helper method that is also needed to be in a model. I’ve done it with just including some helpers in my model, but the same approach is not working on Rails 3.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
and the error information I have
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'
any suggestion/advice?
I also got hit with the error working with Rails 3.1 RC
Some Rails source tracing and I discovered the missing include ActionView::AssetPaths.