Recently, I have been following a tutorial/example from codeschool and everything is going well. However, the example code includes the line:
App.ApplicationAdapter = DS.FixtureAdapter.extend();
Now, I want to maintain all the existing functionality but move the product data to an external JSON file.
Below is a snippet of my app.js file:
var App = Ember.Application.create({
LOG_TRANSITIONS: true
});
// Other code here...
App.ApplicationAdapter = DS.FixtureAdapter.extend();
// More code follows...
In addition, I have also included my HTML (index.html) file:
<!DOCTYPE html>
<html>
<head>
// Script and link references here...
</head>
<body>
// Handlebars templates and scripts here...
</body>
</html>
The tutorial suggests creating a JSON file with specific content and changing the adapter in the app.js file to:
App.ApplicationAdapter = DS.RESTAdapter.extend();
I seem to be having trouble linking to the JSON file. Can anyone guide me on how to adjust the ApplicationAdapter to load the JSON file successfully?
UPDATE
To simplify this question:
I have index.html, app.js, and products.json files in the same directory
I need to update my app.js file as follows:
App.ApplicationAdapter = DS.RESTAdapter.extend({ xxxxxxxxx });
What should replace 'xxxxxx' in order to load my json file?
UPDATE
Update: I have managed to solve the issue! It turns out that I needed to include the path to my directory in the 'host' property:
App.ApplicationAdapter = DS.RESTAdapter.extend({
host: '/name of directory'
});
In my case where my project resides at localhost/ember, the following configuration works:
App.ApplicationAdapter = DS.RESTAdapter.extend({
host: '/ember'
});