我有一个键值对数组:
FEEDBACK_NOTIFICATION = [['Only in reports', 'only_in_reports'],['Immediately', 'immediately']]
在我看来,我尝试过:
<%= f.select(:feedback_schedule, FEEDBACK_NOTIFICATION, options ={:prompt => "-Select-"}) %>
<%= f.select(:feedback_schedule, options_for_select(FEEDBACK_NOTIFICATION), options ={:prompt => "-Select-"}) %>
<%= f.select(:feedback_schedule, options_for_select(FEEDBACK_NOTIFICATION, selected: feedback_schedule), options ={:prompt => "-Select-"}) %>
即使数据库已更新,当我返回编辑页面时,这些似乎都不会显示所选/更新的值。
答案 0 :(得分:2)
&lt;%= f.select(:feedback_schedule,options_for_select(FEEDBACK_NOTIFICATION,selected:@ object.feedback_schedule),options = {:prompt =&gt;&#34; -Select - &#34;})%&gt;会工作