I'm implementing select2 tagging with a has_many through relationship. My implementation has 2 different scenarios.
Scenario 1 works well for tagging. Scenario 2 seems to work but does not save the values. My problem seems to come down to my my input elements for the scenarios.
Scenario 1 uses:
<%= f.association :repairers, labelmethod: :repname, valuemethod: :id, includeblank: true, label: 'Repairer'%>
and when the form is submitted gives params similar to:
"repairer_ids"=>["", "1132", "1131"]
Scenario 2 uses:
<%= f.hiddenfield :repairtypeid, :class => "required on-the-fly-select select"%>
and uses a lot of js code to implement on the fly input for the select menu. When the form is submitted the data will look like: "repairtype_id"=>"5688,5690"
So with scenario 2 the ids are not submitted as an array. I have tried changing the select to: <%= hiddenfieldtag("repairitem[repairtypeids]", "", :id => "repairitemrepairtypeids", :class => "required on-the-fly-select select") %>
but then the relevant param is submitted as one array: "repairtype_ids"=>["5688,5690"]
Are you able to comment on this? Have you ran into this problem?