View Full Version : Ruby on Rails nested JSON problem

13 Jan 2011, 6:45 AM
I am trying to create a form with Sencha Touch that will create a new Task in a simple Rails 3 application. To begin with I am just hardcoding the params into the request. The Rails app was created using:

$rails g scaffold task name:string

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 sends like this:
Parameters: {"_json"=>"task=%5Bobject%20Object%5D"}

I have Googled the mess out of this to no avail. Any ideas?