I have problems with ember-data. For example, I've created a project at http://localhost/~me/test
In my project I've created a store and a model as follows:
... init stuff here ...
var attr = DS.attr;
App.Person = DS.Model.extend({
firstName: attr('string'),
lastName: attr('string'),
});
App.Store = DS.Store.extend({
revision: 11,
adapter: DS.RESTAdapter,
});
Now when I search (somewhere in my route) for a person like this
var person = App.Person.find(params);
The http://localhost/persons?post_id=10 is called. This one does not exist of course. I would've expected something like http://localhost/~me/test/persons?post_id=10. Even better would be http://localhost/~me/test/persons.php?post_id=10 How can I change this url ?
To take care of the prefix, you can use the namespace
property of DS.RESTAdapter
. To take care of the suffix, you'll want to customize the buildURL
method of DS.RESTAdapter
, using _super()
to get the original functionality and modifying that. It should look something like this:
App.ApplicationAdapter = DS.RESTAdapter.extend({
namespace: '~me/test',
buildURL: function() {
var normalURL = this._super.apply(this, arguments);
return normalURL + '.php';
}
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With