开发者

where to find documentation on how to develop (rails 3) helpers [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.

We don’t allow questions seeking recommendation开发者_开发百科s for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.

Closed 5 years ago.

Improve this question

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜