js/libs/ember-1.5.1.js
function(params, transition) {
    var match, name, sawParams, value;

    for (var prop in params) {
      if (prop === 'queryParams') { continue; }

      if (match = prop.match(/^(.*)_id$/)) {
        name = match[1];
        value = params[prop];
      }
      sawParams = true;
    }

    if (!name && sawParams) { return Ember.copy(params); }
    else if (!name) {
      
        if (transition.resolveIndex !== transition.state.handlerInfos.length-1) { return; }

        var parentModel = transition.state.handlerInfos[transition.resolveIndex-1].context;

        return parentModel;
          }

    return this.findModel(name, value);
  }
function(params, transition) {
    var match, name, sawParams, value;

    for (var prop in params) {
      if (prop === 'queryParams') { continue; }

      if (match = prop.match(/^(.*)_id$/)) {
        name = match[1];
        value = params[prop];
      }
      sawParams = true;
    }

    if (!name && sawParams) { return Ember.copy(params); }
    else if (!name) {
      
        if (transition.resolveIndex !== transition.state.handlerInfos.length-1) { return; }

        var parentModel = transition.state.handlerInfos[transition.resolveIndex-1].context;

        return parentModel;
          }

    return this.findModel(name, value);
  }
A hook you can implement to convert the URL into the model for
this route.

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

The model for the `post` route is `App.Post.find(params.post_id)`.

By default, if your route has a dynamic segment ending in `_id`:

The model class is determined from the segment (`post_id`'s
class is `App.Post`)
The find method is called on the model class with the value of
the dynamic segment.

Note that for routes with dynamic segments, this hook is only
executed when entered via the URL. If the route is entered
through a transition (e.g. when using the `link-to` Handlebars
helper), then a model context is already provided and this hook
is not called. Routes without dynamic segments will always
execute the model hook.

This hook follows the asynchronous/promise semantics
described in the documentation for `beforeModel`. In particular,
if a promise returned from `model` fails, the error will be
handled by the `error` hook on `Ember.Route`.

Example

```js
App.PostRoute = Ember.Route.extend({
model: function(params) {
return App.Post.find(params.post_id);
}
});
```

@method model
@param {Object} params the parameters extracted from the URL
@param {Transition} transition
@param {Object} queryParams the query params for this route
@return {Object|Promise} the model for this route. If
a promise is returned, the transition will pause until
the promise resolves, and the resolved value of the promise
will be used as the model for this route.