実にシンプル。
class Template
def stuff_i_want
stylesheet_link_tag('my_stylesheet')
end
class << self
include ActionView::Helpers::TagHelper
include ActionView::Helpers::AssetTagHelper
end
end
そして、これが戻ってきます..
undefined local variable or method `config' for Template:Class
from /Users/elephanttrip/.rvm/gems/ruby-1.9.3-p385@shasta/gems/actionpack-3.1.12/lib/action_view/helpers/asset_tag_helpers/stylesheet_tag_helpers.rb:137:in `stylesheet_link_tag'
stylesheet_tag_helpers.rb
Railtieから:
def stylesheet_link_tag(*sources)
@stylesheet_include ||= StylesheetIncludeTag.new(config, asset_paths)
@stylesheet_include.include_tag(*sources)
end
構成はそのファイルのどこにもインスタンス化されていないので、どこかから必要であると想定しています..どこで、どのようにかわかりません。
私のヘルパーに構成を注入/渡す方法を知っている人はいますか? これまでこれを行う必要はありませんでした。