How do you access RESTAdapter's host and namespace inside a route or controller?
ember-data, ember.js
Solution
turns out you can access the Adapter from the store via `this.store.adapterFor('application')`
The new `submitLogin` method could look like this:
submitLogin: function(user, pass) {
var data = { username: user, password: pass },
host = this.store.adapterFor('application').get('host'),
namespace = this.store.adapterFor('application').namespace,
postUrl = [ host, namespace, 'login' ].join('/'); // http://192.168.2.10/api/v1/login
Ember.$.post(postUrl, data).then();
}
Problem
I have a few custom AJAX requests that I use inside of some controllers and routes, for example: ``` var loginRoute = Ember.Route.extend({ actions: { submitLogin: function(user, pass) { var data = { username: user, password: pass }; Ember.$.post('http://192.168.2.10/api/v1/login', data).then(); } } }); ``` This works fine, but while developing I may have a different IP (e.g. changing routers) and I'd like to be able to access the URL(host + namespace) I defined when I extended the RESTAdapter so that I only have to change the `host` and/or `namespace` once, instead of every place where I do a custom ajax request. ``` App.ApplicationAdapter = DS.RESTAdapter.extend({ host: 'http://192.168.2.10', namespace: 'api/v1' }); ```