Ruby on Rails 4 - simple_form multiple select input

Travis Glover picture Travis Glover · Mar 4, 2014 · Viewed 28.3k times · Source

I have a simple_form input field that looks like this:

<%= f.input :particular_users, collection: @all_users, input_html: { class: 'multiselectuser', multiple: true} %>

When I leave multiple: true off, the form submits the chosen value for the parameter :particular_users and I can see the value when debugging using "raise params.inspect". However when I leave the multiple: true option there, no vales get passed for the parameter :particular_users.

What am I doing wrong?

EDIT: I can not use the association input because :particular_users is a virtual attribute and has no relationship. I want the multiple select box to pass whatever values that are in there, even if they are arbitrary.

Answer

user3177153 picture user3177153 · Apr 1, 2015
f.input :days, collection: @your_collection, input_html: { multiple: true }