I am trying to create a form with Sencha Touch that will create a new Task in a simple Rails 3 application. I am essentially adding nested JSON to this question.
To make testing it easy I am hardcoding the params into the request. The Rails app was created using:
$rails g scaffold task name:string
Sencha Touch Ajax request:
Ext.Ajax.request({
url:'/tasks',
method:'POST',
params: {
task: { name: "Hello World" }
}
Rails expects the params hash to look like this:
Parameters: { "task"=>{"name"=>"Hello World"} }
But the Ajax POST from Sencha sends it like this:
Parameters: {"task"=>"[object Object]"}
When I try using defaultHeaders like:
Ext.Ajax.defaultHeaders = {
'Content-Type': 'application/json'
}
It posts like this:
Parameters: {"_json"=>"task=%5Bobject%20Object%5D"}
Any thoughts on how to handle this properly?