Custom Dynamic Segment (NOT ID) - EmberJS

I want to have a dynamic segment path in Ember without using the :id attribute

As per the Ember Guides, I’m using the serialize method to achieve this.

Heres my Router:

 App.Router.map(function() {
    this.resource("orders", function(){
    	this.resource('order', { path: ':order_sequence'}, function(){
    	    this.route('edit');
    	})
    });
});

And my Route:

var OrderRoute = Ember.Route.extend({
   model: function(params) {
     return this.store.find('order', params.order_sequence)
   },
   serialize: function(model) {
     return { order_sequence: model.get('sequence') };
   }
});
    
module.exports = OrderRoute;

However, my URL’s still behave using the id attribute in the path instead of the sequence attribute…

Any ideas?

1 Like

I just added the model class:

App.Order = Ember.Object.extend({
  sequence: ''
});

And it works for me with the latest starter kit, see the jsbin here