Sencha Touch 2 JSONP response with Ruby on Rails

I had a hard time how to make JSONP response data render in a Sencha Touch 2 list view, but I made it. WOOT.

Maybe, truth to be spoken, I had a harder time figuring out how JSONP actually worked. I had to understand that I had to wrap the JSON object into a JavaScript callback function and change the content type of the response to “text/javascript”. ( I still don’t get it. ;) )

So, here’s the code:

The last line of the the index method will be clear when you understand read the query string parameters which Sencha sends to the server:

and, ultimately the Sencha Store object:

I wonder if you can write a more elegant method?