How to make the f.select rails selected

后端 未结 4 1956
春和景丽
春和景丽 2021-02-07 02:32

It\'s my code:

<%= f.select :area, options_for_select([[\'a\',\'a\'],[\'b\',\'b\'],[\'c\',\'c\']]), {}, {:class => \'span3 controls controls-row\'}, :selec         


        
4条回答
  •  别那么骄傲
    2021-02-07 03:08

    Below is what worked for me using f.select with custom names and values including a blank field while using the Ransack search. Thanks to mayorsanmayor's example for getting me started in the right direction. This also works for rails 5.1.7.

                    <%= f.select(:status_eq, options_for_select([ ["Verified", "verified"], ["Non Verified","notVerified"]], selected: @q.status_eq || nil), {:include_blank => "Select Status"}, {class: 'form-control'}) %>
    

提交回复
热议问题