Created
September 4, 2014 17:34
-
-
Save sgringwe/1353c3e26993ab91dfa6 to your computer and use it in GitHub Desktop.
select2 remote ajax multiple fix for rails
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Rails expects an array of ids but because select2 uses a hidden input for multiple-ajax configuration, it returned a comma separated string. To get around this I did a check and conversion at the beginning of my strong params function: | |
if params[:interview_schedule] and params[:interview_schedule][:contact_ids] and params[:interview_schedule][:contact_ids][0].include?(",") | |
params[:interview_schedule][:contact_ids] = params[:interview_schedule][:contact_ids][0].split(",") | |
end | |
Thanks to https://coderwall.com/p/cxrwsw# for the motivation. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment