Linda Keating
Linda Keating

Reputation: 2435

Ember routes specifying a different root url

I've an application running on my wamp server. The directory structure looks like this Wamp/www/applicationliveshere However I've an ember application within the same directory and it's structure looks like this Wamp/www/emberApp/applicationliveshere I've set up my php project using REST so that I can access the my data using eg. Get http:localhost/emberApp/videos will return all the videos in the database as Json to the client. However my problem is in Ember I'm unsure how to set up my routes to use localhost/emberApp/videos. Currently each time I load the page the controller is using localhost/videos and returning with the a 404 Not found. I am using 'ember-data.js' to handle my models. And I have created a Store as follows

Videos.Store = DS.Store.extend({ revision: 12, url: "http://localhost/emberApp/"})

My Videos route is defined like this

Videos.VideosRoute = Ember.Route.extend({ model: function(){
return Videos.Video.find();
}
});

I also have the path set as follows

Videos.Router.map(function({
this.resource('videos', {path: '/'});
});

So to clarify I want all my routes to begin with http://localhost/emberApp/..... But at the moment I have http://localhost/....

Any ideas?

Thanks in advance.

Upvotes: 2

Views: 942

Answers (1)

intuitivepixel
intuitivepixel

Reputation: 23322

For the behavior you need you should also define the namespace on the adapter additionally to the url in the store.

For example:

App.Adapter = DS.RESTAdapter.extend({
  namespace: 'emberApp'
});

Videos.Store = DS.Store.extend({
  revision: 12, 
  url: "http://localhost/",
  adapter: App.Adapter
});

This will result in http://localhost/emberApp/ as your base url. Have also a look here for info on that.

Hope it helps.

Upvotes: 3

Related Questions