模型中的Rails 3 View辅助方法 [英] Rails 3 View helper method in Model
本文介绍了模型中的Rails 3 View辅助方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的模型中有一个类方法,我需要从我的一个视图助手中访问一个方法.目前,我包含include TalkHelper
,但仍然出现NoMethodError.
I have a class method in my model, and I need to access a method from one of my view helpers. Currently I am including include TalkHelper
, but I still get a NoMethodError.
推荐答案
您可以将helper放在lib文件夹中,然后在其中包含它们. 像这样: lib/some_helper.rb
You may place helper in your lib folder and include them anythere. Like this: lib/some_helper.rb
module SomeHelper
def somedef
#your code there
end
end
这篇关于模型中的Rails 3 View辅助方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文