I'm desperately trying to get slugs in Ember 1.x working.
My serialize method seems to work fine. I can navigate to my route with no problem using the link-to helper or transitionToRoute method. But when I reload my page i get a bunch of errors because my promise resolves in an array of models instead of a single model.
How do I reduce the result of findQuery to one model?
I found a helpful answer for an older Ember.js version here: Using a slug in an emberjs route Unfortunately the solution doesn't work anymore. "one" is not defined, so i tried to adapt my code to the current version. According to the promise documentation, a return value in the then method of the promise object should be passed to the next handler. But I'm still getting an array and my errors afterwards.
My route implementation:
App.ManageRoute = Ember.Route.extend
model: (params) ->
promise = @get('store').findQuery('company', {slug: params.company_id})
promise.then (models) ->
return models.get("firstObject")
return promise;
serialize: (model, params) ->
return {company_id: model.get('slug')}
[Update]
The solution is to create and return a new Promise object for the single model.