RoR select_tag default value & options

后端 未结 5 1723
隐瞒了意图╮
隐瞒了意图╮ 2020-12-13 23:38

How can I set a default value using select_tag, and how can I keep the options open on page load?

5条回答
  •  执笔经年
    2020-12-14 00:23

    Try this:

    <%= select_tag(:option, options_for_select([["Option 1",1],["Option 2",2],["Option 3",3]], params[:option] ), class:"select") %>
    

    works great in rails 5.

提交回复
热议问题