Sortable List, Serializing and Parsing with Ruby

OmenKing
Wed, 30 Jan 2008 16:40:38 -0000

I have a sortable list that I serialize and pass to ruby to parse the
results and update my array of hashes.
eg.

$tasks = [
  { :id => 1, :name =>  ''Do the dishes'', :position =>
3 },
  { :id => 2, :name => ''Take out the trash'', :position
=> 2 },
  { :id => 3, :name => ''Shovel the driveway'', :position
=> 1 }
]

My hurdles:

(1) serializing and passing with Ajax

var list = Sortable.options(''tasks'').element;
new Ajax.Request(''/tasks'', { parameters:
Sortable.serialize(list)});

I get this:

tasks%5B%5D=2&tasks%5B%5D=1&tasks%5B%5D=3

would it be more useful if It was formating it as such?
task{id}={position}&

Where are the %5B%5D coming from?

(2) parsing it in ruby

I grab the request with web brick and I pass the query to params

params = request.query

How do I go about parsing it and updating my array of hashes?