My form have collection select but no saving to database Form tryings assign player id to "pretender" record
database models:
create_table "players", force: :cascade do |t|
t.string "name"
t.string "group"
t.text "info"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
end
create_table "pretenders", force: :cascade do |t|
t.string "name"
t.string "archtype"
t.string "magic"
t.string "scale"
t.integer "player_id"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
end
in form partial:
<div class="field">
<%= form.label :player_id %>
<%= form.collection_select(:player_id, Player.all, :id, :name, {}, {:multiple => true, :size => '10'}) %>
</div>
generated html select options have value but not saving?
<select multiple="multiple" size="10" name="pretender[player_id][]">
<option value="1">sy</option>
<option value="2">malakal</option>
<option value="3">pigs go moo</option>
<option value="4">malgrib</option>
<option value="5">Rael</option>
<option value="6">Nargo</option>
<option value="7">salva</option>
<option value="8">pbiecub</option>
<option value="9">Jude</option>
<option value="10">Cirno</option>
</select>
here params at pretender controller:
def pretender_params
params.require(:pretender).permit(:name, :archtype, :magic, :scale, :player_id)
params.require(:pretender).permit(:id)
end
Am attempt solution at: Collection_select not saving & other pages, but site won't let me post more links lol
Aucun commentaire:
Enregistrer un commentaire