Hi!
I'm following the same tutorial. I finally could make it fully work with WO (creating, updating, deleting, etc).
I did the following changes:
1) SC expects variables to be camel-cased and not underscored. The SproutCore format created on ERRest was set to underscore variables, so isDone was being converted to is_done, and it would not work (tasks fetched from the server would never be ticked).
2) As you noticed, "records" should be "content". I submitted a patch to ERRest fixing this problem and the previous.
3) All URLs have to be adapted, including Update and Delete URLs that have to be built like this:
SC.Request.putUrl('/WO/WebObjects/Todos.woa/-6666/ra/Task/' + store.idFor(storeKey) + '.sc').json()
4) Apparently, who wrote the tutorial assumed the backends would return an object in response to the PUT request. ERRest will always return an array, so you have to get objectAt(0) on the client side. This is a little hard to fix in ERRest, however, I believe it's not broken at all. The thing is, there appears to be no well defined conventions or standards on this (which is always nice for a protocol...), which means it's really however the app developer wants it to be. So, if you're using ERRest, you want it to be an array. ;)
I think those were all the issues. I attach my data source file so you can compare. If you adjust the URLs to match yours, it should be just a matter of dropping it in on your client and it should work.
If you want, please feel free to update Wonder's wiki! ;)
Yours
Miguel Arroz
|