Mon modèle est indiqué ci-dessousRoR sélectionnez Options des balises
class Question < ActiveRecord::Base
ANSWERS= ['Option 1', 'Option 2', 'Option 3', 'Option 4']
end
Dans la vue <%= select(:question, :answer, Question::ANSWERS, {:include_blank => true}) %>
sorties
<select name="question[answer]" id="question_answer">
<option value=""></option>
<option value="Option 1">Option 1</option>
<option value="Option 2">Option 2</option>
<option value="Option 3">Option 3</option>
<option value="Option 4">Option 4</option>
</select>
j'ai essayé <%= select(:question, :answer, Question::ANSWERS.collect {|d| [d, Question::ANSWERS.index(d)]}, {:include_blank => true}) %>
Cela donne
<select name="question[answer]" id="question_answer">
<option value=""></option>
<option value="0">Option 1</option>
<option value="1">Option 2</option>
<option value="2">Option 3</option>
<option value="3">Option 4</option>
</select>
Mais j'ai besoin la sortie suivante
<select name="question[answer]" id="question_answer">
<option value=""></option>
<option value="1">Option 1</option>
<option value="2">Option 2</option>
<option value="3">Option 3</option>
<option value="4">Option 4</option>
</select>
super, merci !! –