Closed ricardogsilva closed 11 years ago
One problem might be that the adapter does not expect you to pluralize the name of the model. If you don't want to set up special URL parameters, you should use http://localhost:8000/#/garden. That is the one the adapter is doing automatically when using .find().
Also, the returned data does not include the "id" fields. Are you removing them with a meta option in the server?
OK, my tastypie URL looks like
http://localhost:8000/api/v1/garden/
It already looked like this before. In the previous post I had shown the ember URL. I think this is what you meant when you said I should not pluralize the model's name.
I was previsouly refering to the URLs that are routed in the ember app. I also changed that URL to:
http://localhost:8000/#/garden/
to be on the safe side.
I also changed the server's response and it now includes the id field (among some others):
{
"meta": {
"limit": 20,
"next": null,
"offset": 0,
"previous": null,
"total_count": 2
},
"objects": [
{
"active": true,
"created": "2013-01-16T00:37:50.779194",
"geom": null,
"id": 1,
"modified": "2013-01-16T00:37:50.779242",
"name": "Horta da Velha",
"resource_uri": "/api/v1/garden/1/"
},
{
"active": true,
"created": "2013-01-16T00:38:02.608067",
"geom": null,
"id": 2,
"modified": "2013-01-16T00:38:02.608116",
"name": "Horta do Monte",
"resource_uri": "/api/v1/garden/2/"
}
]
}
But I am getting the same error as before. Any other hints?
Ok, I managed to get it to work now.
I guess the latest commit fixed it, as I can now access the objects returned by tastypie. Thanks!
If I include tastypie_serializer.js before tastypie_adapter.js it works. The other way around it throws that error :)
Exactly. The serializer is a dependency of the adapter. Also, the two files should be used only during development in case you want modify them. You should always build a single file with this methods (https://github.com/escalant3/ember-data-tastypie-adapter#javascript-side) or your own for production.
Ruby tools for a Django project? ;) webassets can take care of that on the fly for django projects
"Or your own" :)
Hi. I'm going through the ember guides, trying to connect my tastypie API to an ember application. I've pulled the latest ember, ember-data and ember-data-tastypie-adapter code from their respective repos. Getting my data out of the server, I get:
My ember application:
when I visit the http://localhost:8000/#/gardens URL, using Firebug, I can see that the request for data is sent to the server and that the response is correct. Response:
However, I am getting the following error in the console:
What could be the problem? Is my model badly defined? Maybe some convention name I am not respecting?
Thank you