what i did:
rails g scaffold game optionselect:string
rake db:migrate
in my view inside the form_for(@game):
<div class="field">
<%= f.label :optionselect %><br />
<%= f.select( :optionselect, "id", { "Option 1" => "1", "Option 2" => "2"}) %>
</div>
what i want to do:
select a value from the selectbox and save the selected value in @game.optionselect
problem: there are no selectable values visible. when i leave out the f. in front of f.select the values are visible but are not being saved (which i’m aware of).
It is good practise to keep such collections in the model and create class method to prepare them, ex:
then in the view: