vendredi 23 décembre 2016

How to connect Rails collection route to Ember JSON API Adapter?

I have a Rails resource like this...

resources :listings do
  collection do
    get :stats
  end
  ...
end

such that GETting /listings/stats?various_params gives me a JSON API compliant response with statistics about the Listing model according to the parameters I provide.

In my Ember frontend, also using the JSON API Adapter, I would like to be able to something like this:

model() {
  return this.store.query('listing/stats', {startdate: startDate.toISOString, otherparams: etCetera});
}

What's the "Ember Way" to accomplish this, if any? I would like to avoid hacking the JSON API Adapter as much as possible, and it's my understanding that custom methods defined on an Ember model's file are mostly for interacting with a specific record (i.e., /listings/:id/whatever)

Thanks




Aucun commentaire:

Enregistrer un commentaire