Remote (ajax) multi-select in Rails with Select2
Remote multi-selection using select2 works by placing results into a hidden input
field.
When posting to a controller action this will not be converted to an array (Rails only treats multiple inputs with the same id and a little sugar as an array, see: stackoverflow).
To get around this you can define a getter/setter method on your model to handle the array conversion.
This gist includes a light module for accomplishing this and hopefully enough sample code to help you get up to speed.
Written by Cyrus Farajpour
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Rails
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#