emberjs/ember.js — pull request #2933 by southpolesteve (2013-07-01 19:53:54+00:00)
Title: Improvements to route serialize hook.

It seems to me that we could make the default serialize hook smarter about how it gets information from the model. Consider the following (slightly simplified) code extracted from my own app that browses a list of Github repos:

``` javascript
Github.Router.map(function() {
this.resource('repo', { path: '/:owner/:name' });
});

Github.RepoRoute = Ember.Route.extend({
model: function(params) {
return Github.Repo.find(params);
},
serialize: function(model, params) {
return { owner: model.get('owner'), name: model.get('name') };
}
});
```

Template:
```
{{#linkTo 'repo' repo}}{{repo.full_name}}{{/linkTo}}
```

The serialize hook could be intelligent in cases where the data and URLs are not structured around IDs but other properties on the model. If I define my path as `/:owner/:name` it would try and construct the URL using `model.get('owner')` and `model.get('name')`. Does that make sense?

This PR is just a starting point for discussion that covers my own use case. I would still like to add a test, get some feedback on the general idea, and hear any other cases that might make sense to be handled by the default serialize hook.