Inherited resource

Hi,

I’ve abstract Model

Filter = DS.Model.extend(Ember.Validations.Mixin,
  type:                     DS.attr("string"),
  name:                     DS.attr("string")
  description:              DS.attr('string')

and an inherited model:

status = Filter.extend(
  pattern:            DS.attr("string")
)

My server json for a status (filter is abstract):

{"filters": 
  {"id": "oZnGUb8MKgLX",
   "type": "status",
   "name": "Error status",
   "description": "",
   "pattern": "201-210"}}

When i try to load a status (http://localhost/filter/filter_id), i’ve a filter instance not a status instance.

I want to receive the good type of filter , if my filter is a status , i want load a status instance not a filter instance . If i implement a status route etc… it work , but i don’t want create mvc for all inherited resource of filter… What is the good way ?

Michael

You will want to look at how ember-data handles polymorphism. https://github.com/emberjs/data/search?q=polymorphism&type=Issues&utf8=✓

Thks Juilien , i’ve already search here , but i don’t find solution… When i load a model whith link-to method all work , but when i refresh it don’t work . I’ve understand why it don’t work , but i wish they are another way to resolve it .

I’ve don’t find a good way to do this… I’ve simply add find model in setupcontroller method:

setupController: (controller, model) ->
    controller.set('model', @store.find(model.get('type'), model.get('id')))

It’s not clean because in several case , i call 2 times my model and i supose it’s not the good place … But it work and i dont have any other solution…