vendredi 29 mai 2015

Customizing PUT route on save method in ember.js

I would like to manually specify a PUT route for saving my model. Is this possible with ember?

For example, I have a conversation model and when I call conversation.save(), I don't want it to search for the PUT conversations/someMail/conversations/:id but to manually tell ember to use PUT /conversations/:id instead.

Here is my namespace :

App.ApplicationAdapter.reopen({

namespace: 'conversations/someEmail'

});

Router :

App.Router.map(function(){

//Routing list to raw namespace path
this.resource('conversations', { path : '/' }, function() {
    this.resource('conversation', { path : '/:conversation_id'});
});

});

Model :

App.Conversation = DS.Model.extend({

readStatus: DS.attr('string'),
url: DS.attr('string'),
status: DS.attr('string'),
lastMessage: DS.attr('string'),
createdAt: DS.attr('string'),
timeAgoElement: DS.attr('string'),
customer: DS.belongsTo('customer'),
content: DS.attr('array'),

});




Aucun commentaire:

Enregistrer un commentaire