我无法使用select_tag获取选定的值。 在我new.html.erb,我有以下代码:Ruby on Rails select_tag选定值
<%= select_tag "dams_provenance_collection[subjectType][]", options_for_select(subjectTypeArray), :prompt=>"Select subject type" %>
和edit.html.erb,我想从new.html.erb使用选择的值作为默认的,所以我尝试:
<%= select_tag 'dams_provenance_collection[subjectType][]', options_for_select(subjectTypeArray, params[:selected]) %>
但它没有工作。有没有人知道如何在edit.html.erb中将new.html.erb中的选定值设置为默认值?任何帮助,将不胜感激。
我认为这是错误的,你应该通过'selected'选择'select_tag'不是选项 –
或者如果你想这样做,只需将选择的(默认)作为第二个参数。 –
@MichaelSzyndel:OKie ..让我检查一下,然后编辑..谢谢.. – Jyothu