Skip to content

Instantly share code, notes, and snippets.

@Geokoumpa
Created April 28, 2014 08:30
Show Gist options
  • Save Geokoumpa/11365481 to your computer and use it in GitHub Desktop.
Save Geokoumpa/11365481 to your computer and use it in GitHub Desktop.
Ember-model findMany implementation
# this calls to a resource collection path adding an 'ids' param with comma separated ids, e.g. /posts?ids="1,2,3"
Ember.RESTAdapter.reopen findMany: (klass, records) ->
url = @buildURL(klass)
params = ids: records._ids.join(",")
@ajax(url, params).then (data) ->
collectionKey = Ember.get(klass, "collectionKey")
dataToLoad = (if collectionKey then Ember.get(data, collectionKey) else data)
Ember.run records, records.load, klass, dataToLoad
return
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment