在哪里可以找到有关如何开发(rails 3)帮助器的文档 [英] where to find documentation on how to develop (rails 3) helpers
问题描述
我正在寻找的答案是:
我有一个局部视图(说shared / _error_messages.html),它的帮助应该在哪里去,我该怎么命名,哪些约定?
如何将局部变量从视图传递给助手,反之亦然?
是的,我们从基础知道...
提前感谢
将方法从_error_messages.html.erb提取为helpers / application_helper.html.erb,这是一个全局帮助者,这意味着整个项目中可用的方法。
您可以将其作为部分留下,并将其加载到
<%= render:partial => shared / error_messages%>
。
I may be blind but I can't really find any good documentation on how to write helpers for your own views in rails 3. The kind of answers I'm looking for is:
I have a partial view (say shared/_error_messages.html), where should its helper go, how should I name it, which are the conventions? How to pass local variables from the view to the helper and vice-versa?
Yeap, so let's say from the basics... Thanks in advance
Extract the method from _error_messages.html.erb to helpers/application_helper.html.erb, this is a global helper, which means the methods there are available in the whole project.
You could leave it as a partial and load it with
<%= render :partial => "shared/error_messages" %>
as well.
这篇关于在哪里可以找到有关如何开发(rails 3)帮助器的文档的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!