vendredi 8 mai 2015

How to create route in right way?

I need to create 2 route

/users/philosophy

/topic/philosophy

On /users/ there is a list of categories and on topic is a list of categories. On /users/philosophy there is list of users by category and the same for topic. Categories are same. So I created router:

this.resource('categories', { path: '/:section' }, function(){
    this.resource('category', {path: '/:url'});
});

And it works. But now I want to add filter /users/philosophy/top for list of users. I tried to do it like that:

this.resource('categories', { path: '/:section' }, function(){
    this.resource('category', {path: '/:url/:filter'});
});

But if remove segment top from url, it throw error, so filter param became necessary. How can I make filter param unnecessary? Or please another way to build router.




Aucun commentaire:

Enregistrer un commentaire