firstObject in Router model() function?


#1

In this case:

model: function (params) {
    return Ember.RSVP.hash({
      room: this.store.find('room', {url:params.room_url}),
      user: this.store.find('user', 1)
    });
  },

How do I set the “room” model to a firstObject? (I have solved this in a beforeModel function, but that seems unnecessary.)


#2
setupController: function(controller, model) {
   model.set('room', model.get('room.firstObject'));

   this._super.apply(this, arguments);
}

#3

Another alternative:

model: function(params) {
  return Ember.RSVP.hash({
    room: this.store.find('room', {url:params.room_url}).then(function(result){ 
      return result.get('firstObject');
    }),
    user: this.store.find('user', 1)
  });
},