How to call items on RSVP hash result?


#1

Setting multipel models in a single route involves using RSVP.hash, which returns a recordarray object.

I can’t seem to grab a single record out of it.

  model: (params) ->
    Ember.RSVP.hash
      modelActive: this.modelFor('personalities').findBy('type', this.paramsFor('personalities').activeType)
      modelOther:  this.modelFor('personalities').findBy('type', params.otherType)
      modelIR:  this.store.find('intertype-relation')

In the controller, let’s say I try to access one model to do some presentation logic (e.g. uppercase-ing).

this.get('model.modelIR')

This is an array of objects. Let’s say I want one. this doesn’t repond to any of the methods .find .findBy .filter .then . It does respond to .get(‘firstObject’) but I obviously want to access other objects in the recordarray, not just the first one.

what’s the proper syntax to extract one record out of a recordarray?


#2

I think you’re looking for http://emberjs.com/api/classes/Ember.Array.html#method_objectAt


#3

Hm. I wonder if that can be used to find records based on other attributes of the record, or even the id, rather than just the index.

The return value of RSVP hash is a RecordArray which is a subclass of ArrayProxy, which has all the usual findBy methods… so I don’t understand why find, and findBy aren’t working.