2
votes

I am very new to EmberJS. I am trying to make a simple Ember CRUD app. I am using Ember Data 's REST adapter. The REST adapter is configured to pull data from a CodeIgniter application.

I have tested the CodeIgniter application and it is serving data correctly.

Here is my Ember code (except the routes)

http://pastebin.com/pWrp6hRz

Here is my router.js file

http://pastebin.com/MzqAjshJ

When I navigate to /users, I get this error:

Error: assertion failed: Error while loading route:
<html><head>
<title>404 Not Found</title>
</head><body>
<h1>Not Found</h1>
<p>The requested URL /users was not found on this server.</p>
</body></html>
, status: 404, statusText: Not Found} @ http://localhost/todo3/js/libs/ember-1.2.0.js:796

A similar error is encountered when I navigate to /departments

Interestingly, if I change the line

App.ApplicationAdapter = DS.RESTAdapter.extend();

to

App.ApplicationAdapter = DS.FixtureAdapter.extend();

and comment out

DS.RESTAdapter.reopen({
  url: 'http://localhost/service_r/index.php'
});

and also add some FIXTURE data...(making absolutely no more changes) then the error dissappears and I can see the data.

What is the problem with RestAdapter?

2
I am not familiar with the "url" property on RESTAdapter. What does that do? Shouldn't you be using the "namespace" or "host" properties? You can read about the RESTAdapter here: emberjs.com/api/data/classes/DS.RESTAdapter.html - Steve H.
My mistake. I swapped 'url' for 'host' and then I could get data. Please post your comment as an answer so that I can mark it. - Shuaib

2 Answers

1
votes

It seems to be a problem on your server as you are getting a 404. Just exactly as the error message shows. You should use the 'namespace' property to ensure you are reaching the correct serverurl.

Edit: Steve H already posted this answer in a comment!

3
votes

I guess I should have posted this as an answer :) Thanks for the vote!

I am not familiar with the "url" property on RESTAdapter. What does that do? Shouldn't you be using the "namespace" or "host" properties? You can read about the RESTAdapter here: emberjs.com/api/data/classes/DS.RESTAdapter.html