0

When using jQuery ajax to post the following to an action in a rails controller:

$.post('/upload/action',
  {
     show: show,
     slides : [
       { id: 311, position: 1 },
       { id: 312, position: 2 },
       { id: 313, position: 3 }
     ]
  }
)

The expectation is that the slides attribute would remain an array but it is being converted into an object.

Expectation

params[:slides] in the upload/action would return:

[
   { id: 311, position: 1 },
   { id: 312, position: 2 },
   { id: 313, position: 3 }
]

Whats actually happening

params[:slides] in the upload/action returns:

{"0"=>{"id"=>"311", "position"=>"1"}, "1"=>{"id"=>"312", "position"=>"2"}, "2"=>{"id"=>"313", "position"=>"3"} }


How is this conversion prevented or undone?

4

0 回答 0