Q:

How to send a Json in order to make an update in Rails?

I am trying to make an update between flex and rails with something like this:
// TODO Auto-generated method stub
var strXml:XML = <test>
<test_id>{txtMarketId.text}</test_id>
<market_name>{txtMarketName.text}</market_name>
</test>;

req = new URLRequest("http://localhost:3000/tests/"+market_id);
jrwloader  = new URLLoader();
params = new URLVariables();
req.data = strXml.toString();                               
req.method = URLRequestMethod.POST;                                                         
req.requestHeaders.push(new URLRequestHeader("X-HTTP-Method-Override", URLRequestMethod.PUT));                                                          
jrwloader.load(req);

In my rails app I got this:
Started PUT "/markets/2" for 10.10.10.10 at 2012-09-08 18:37:24 +0000
Processing by TestController#update as */*
  Parameters: {"test_id:2, market_name:test"=>nil, "id"=>"2"}
WARNING: Can't verify CSRF token authenticity
  Market Load (0.2ms)  SELECT `tests`.* FROM `test` WHERE `test`.`test_id` = 2 LIMIT 1
   (0.1ms)  BEGIN
   (0.1ms)  COMMIT
Redirected to http://localhost:3000/tests/2
Completed 302 Found in 3ms (ActiveRecord: 0.4ms)

I think I am close to the answer but I cannot set the new data into the database.

A:

I solve it! The main issue it was just to add one line in my request. So at the end I got something like this:
req = new URLRequest("http://localhost:3000/tests/"+market_id);
jrwloader  = new URLLoader();
params = new URLVariables();
req.data = strXml.toString();                               
req.method = URLRequestMethod.POST;                                                         
req.requestHeaders.push(new URLRequestHeader("X-HTTP-Method-Override", URLRequestMethod.PUT));                                                          
**req.requestHeaders.push(new URLRequestHeader("Content-type", 'application/xml'));**         jrwloader.load(req);

thanks all!

