Rails select helper - Default selected value, how?

后端 未结 15 1727
臣服心动
臣服心动 2020-11-29 16:06

Here is a piece of code I\'m using now:

<%= f.select :project_id, @project_select %>

How to modify it to make its default value equal

15条回答
  •  刺人心
    刺人心 (楼主)
    2020-11-29 16:43

    This should work for you. It just passes {:value => params[:pid] } to the html_options variable.

    <%= f.select :project_id, @project_select, {}, {:value => params[:pid] } %>
    

提交回复
热议问题