The correct way to determine resource routes in Ember?

In the manuals, I see two ways to determine resource routes, and I was wondering what should I use and why?


Found here: http://emberjs.com/guides/routing/defining-your-routes/

App.Router.map(function() { this.resource('posts'); this.resource('post', { path: '/posts/:post_id' }); }); 

Found here: http://emberjs.com/guides/templates/links/

 App.Router.map(function() { this.resource("posts", function(){ this.route("post", { path: "/:post_id" }); }); }); 

It was strange for me to define 2 posts and post resources when it is actually only a post resource.

+4
source share
1 answer

I believe when you do this,

 App.Router.map(function() { this.resource("posts", function(){ this.route("post", { path: "/:post_id" }); }); }); 

it displays the message template inside the {{outlet}} message template.

when you do it

 App.Router.map(function() { this.resource('posts'); this.resource('post', { path: '/posts/:post_id' }); }); 

message template does not appear when visiting / posts /: post_id

+5
source

All Articles