1

I am attempting to create a feature where users can add an existing record, recipe, to a collection of records, menu. I am using collection_select with a simple_form to allow users to select multiple records from a list however, the form is not responding to the input_html: { multiple: true } option, which should allow users to select multiple values. The form is as below, please let me know if any other code would be helpful for context.

Form:

<%= simple_form_for @menu, local: true do |f| %>

  <%= f.label :title, :class => "form-component-header" %>
  <%= f.text_field :title, :class => "form-field" %>

  <%= f.label :recipe_ids %>
  <%= f.collection_select :recipe_ids, f.object.user.recipes, :id, :title, input_html: { multiple: true } %>

  <%= f.submit :class => "form_button" %>

<% end %>
Tom
  • 1,311
  • 10
  • 18
dsteinbr1
  • 77
  • 11

1 Answers1

0

.permit(....recipe_ids: [])

You need to update the permitted parameters in your controller. Now that you are sending multiple selections the parameter needs to be marked as expecting an array.

Tom
  • 1,311
  • 10
  • 18