As always the documentation is an amazing place to start. Have a look at https://github.com/emberjs/ember.js/blob/master/packages/ember-routing/lib/routable.js#L231-273 for the default serialize/deserialize methods.
You have the right idea though.
- Ember takes the closest dynamic segment e.g.
blog_post_id
- Strips the
_id
from the end, leaving blog_post
- Calls
Ember.String.classify('blog_post')
which returns BlogPost
- It looks for that modelClass under the Ember namespace e.g. App.BlogPost
- It calls find on that model. e.g. App.BlogPost.find(1)
EDIT:
In response to Neppord's comments, he asked about multiple dynamic segments.
Yes ember-router does currently support multiple dynamic segments in a single route.
Ember.Route.extend({
route: "/:post_type/:post_id"
})
If you really need it like that you would have to write your own deserialize/serialize methods.
Personally I'd just use a nested dynamic state instead.
Ember.Route.extend({
route: "/:post_type"
post: Ember.Route.extend({
route: "/:post_id"
})
})