Skip to content

Instantly share code, notes, and snippets.

@sgringwe
Created September 4, 2014 17:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sgringwe/1353c3e26993ab91dfa6 to your computer and use it in GitHub Desktop.
Save sgringwe/1353c3e26993ab91dfa6 to your computer and use it in GitHub Desktop.
select2 remote ajax multiple fix for rails
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