2
在我注册我有Choose a Question
下拉:代码如下如何添加默认选择选择一个字段选项到我的下拉导轨?
<%= f.select("question_id", Question.all.collect {|p| [ p.body, p.id ] }])) %>
,我想要得到的输出像下面
<select name="question" id="login_fields_question" class="signup_fields" >
<option value="choosequestion" selected="selected" style="font-style:italic;">Choose a question ...</option>
<option value="1"> What is your pet name?</option>
<option value="2">What is the name of your best friend from childhood?</option>
<option value="3">What was the name of your first teacher?</option>
<option value="4">What is the name of your manager at your first job?</option>
<option value="5">What was your first phone number?</option>
<option value="6">What is your vehicle registration number?</option>
随着代码f.select
我能得到的所有问题从数据库,但我怎样才能添加Choose a question ...
选项,我的下拉?这将显示默认情况下,可能会给出如上输出HTML代码