Rails 3 + Select2 multiple ids + AJAX -


I use selection 2 to create an AJMX call to select users for simple messaging inside my app I am here. Everything seems to be getting the most out of work (even intense seals through ANACage), except that I am tearing off my hair to try to make my hair as an easy thing: everyone's To create a message again, run through several user ids. > The problem, apparently, is that Selection 2 returns several IDs in the form of a string that expects the rail. I have tried that a bunch of things do not seem to work ....

How do I change the string?

  {"username" = & gt; "78,21,12"}   

to

  {"username" = & gt; [78221]}    

Here's a solution:

  h = {"username" = & gt; "78,21,12"} h.map {| A, b {One = & gt; B.split (',')}} Decrease (: merge)   

Product:

  {"user name" => ["78" , "21", "12"]}   

or if you want an integer instead of a string:

  h.map {| A, b {One = & gt; B.split (','). Map (& amp;: to_i)}} Reduce (Merge)   

Product:

  {"user name" = & gt; [78, 21, 12]}    

Comments

Popular posts from this blog

excel vba - How to delete Solver(SOLVER.XLAM) code -

github - Teamcity & Git - PR merge builds - anyway to get HEAD commit hash? -

ios - Replace text in UITextView run slowly -