我試圖創建一個使用Rails 3.一些液體模板一組自定義標籤的我在lib /目錄下增加了一個「liquid_tags.rb」像這樣的內容:Rails 3中液體的自定義標籤找不到
class UserControls < Liquid::Tag
def initialize(tag_name)
super
end
def render(context)
tag = "<b>TAG</b>"
end
end
Liquid::Template.register_tag('user_controls', UserControls)
當我嘗試通過「{%user_controls%}」獲取標籤時,它告訴我找不到標籤。
任何想法?
在此先感謝。
我懷疑這可能是一個問題,但我不明白爲什麼lib /目錄中的文件不會被加載。該目錄中還有其他文件正在正常加載。 – Matt 2010-11-19 16:14:51
關於使用rails 3 beta自動加載的lib /目錄有一些變化。我不得不將lib目錄添加到config/application.rb'config.autoload_paths + =%W(#{config.root}/extras)' – 2011-01-17 21:36:19