REST custom urls


#1

I can’t find a good example of working fully with REST, every example touches only CRUD. REST allows urls as /api/1/reports/general.

How to properly send request to API for nested url?

I’ve tried:

this.store.find('report/general')
this.store.find('report.general')

Last idea was to use just this.store.find('report', { type: 'some-type' }). But this also not gone well, I have different model for reports/general.

I’ll appreciate any help, thanks!

UPDATE:

One idea that actually worked, to use native jQuery Ember.$.getJSON:

model: function () {
    return Ember.RSVP.hash({
      indicator: this.store.find('indicator'),
      profile: this.store.find('profile'),
      conversationUpdate: Ember.$.getJSON('api/1/reports/conversation.json')
    });
  },

Is there any better solution for this?


#2

It doesn’t look like Ember Data supports nested REST resources at the moment. There’s been some discussions around it and a few proposed solutions, but nothing that’s actually shipped as of now (that I know of).

This issue on the Ember Data repo discussed it, and the last reply from Yehuda states (6 months ago) that “I’ll keep it in mind going forward.”

This discussion on these forums also goes through some reasons why nested resources might not be the best solution anyway, as well as possible solutions.

You could probably find some temporary solution by overriding buildUrl in your adapters.