0
我努力使柔性之間的更新,並與這樣的軌道:如何發送Json以便在Rails中進行更新?
// 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);
在我的Rails應用程序,我得到這個:
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)
我想我接近答案,但我不能將新數據設置到數據庫中。
我正在閱讀這個鏈接的信息,但我沒有看到我的代碼中的用法。任何想法? –
您可以在響應主體頭部找到正確的CSRF令牌'' –
我認爲CSRF對更新沒有影響的記錄。我改變它,只是警告消失了,但數據庫沒有改變。 –