Javascript 余烬路由器中不变名词的处理

Javascript 余烬路由器中不变名词的处理,javascript,ember.js,Javascript,Ember.js,我很好奇,当显而易见的单词的单数和复数相同时,其他人是如何处理命名余烬路线的,并且您需要一个显示所有该类型的路线以及单个项目的动态路线 以文档为例: App.Router.map(function() { this.resource('posts'); this.resource('post', { path: '/post/:post_id' }); }); 太好了。现在,如果不是帖子和帖子,而是系列文章呢。您不能再使用此模式。您希望/series成为所有系列的集合,并且/serie

我很好奇,当显而易见的单词的单数和复数相同时,其他人是如何处理命名余烬路线的,并且您需要一个显示所有该类型的路线以及单个项目的动态路线

以文档为例:

App.Router.map(function() {
  this.resource('posts');
  this.resource('post', { path: '/post/:post_id' });
});
太好了。现在,如果不是帖子和帖子,而是系列文章呢。您不能再使用此模式。您希望
/series
成为所有系列的集合,并且
/series/:series\u id
显示每个单独的系列。我想到的只是使用一个较长的名称:

App.Router.map(function() {
  this.resource('series', { path: '/series' });
  // not nested so that series route isn't activated
  this.resource('series-instance', { path: '/series/:series_id' });
});
这里有一个不同的例子,这里的问题不是单词是不变的,而是没有一个单词代表sigular:

App.Router.map(function() {
  this.resource('staff', { path: '/staff' });
  this.resource('staff-member', { path: '/staff/:staff_id' });
});

有没有更好的方法来实现这一点,或者我已经找到了目前最好的解决方案?

基本上,您可以为路径值指定任何您喜欢的内容,而不受语法的影响。 我认为您所描述的是一种有效的方法,我一直在为嵌套资源使用此方法以及以下方法

    App.Router.map(function() {
      this.resource('series', { path: '/series' },function(){
        this.resource('series-instance', { path: '/:series_id' });
      });
    });
通过访问类似于
/series/4
的内容将触发嵌套资源