提示不显示select_tag

时间:2016-08-30 10:09:18

标签: ruby-on-rails

我有以下代码,应该显示带有项目列表的选择标记,默认情况下选择主题'但它没有显示提示项目:

<%= select_tag 'subject', options_for_select(['Hello', 'Billing', 'Other'], {:prompt => 'Select subject'}) %>

任何想法为什么?

我设法使用<%= select_tag 'subject', options_for_select({'Select subject'=>'','Hello'=>'Hello','Billing'=>'Billing','Other'=>'Other'}) %>让它工作但感觉更长时间啰嗦......

2 个答案:

答案 0 :(得分:1)

试试这个!

<%= select_tag 'subject', options_for_select(['Hello', 'Billing', 'Other'], ),:prompt => 'Select subject' %>

答案 1 :(得分:0)

&lt;%= select_tag' subject',options_for_select(['Hello','Billing','Other']),{:prompt =&gt; '选择主题'}%&gt; 在提示之前尝试超过括号。

相关问题