【发布时间】:2015-04-02 09:09:52
【问题描述】:
我正在使用不同的帖子“模板”构建应用程序。除了占位符文本之外,帖子的每个表单都是相同的。我试图弄清楚如何动态设置占位符文本。我一直在尝试将所有模板助手命名为相同的名称,最后保留 @template.id。我似乎无法让动态功能工作。
def title_template_1
'Placeholder for Template 1 Title'
end
def title_template_2
'Placeholder for Template 2 Title'
end
<%= f.text_field :title,
:placeholder => title_template_1 %>
<%= f.text_field :title,
:placeholder => title_template_'#{@template.id}' %>#this doesn't work, but I'm showing it to show the functionality I'm trying to achieve.
谢谢
【问题讨论】:
标签: ruby-on-rails forms dynamic helper placeholder