Controlling Model's typeKey


I’m having trouble figuring the correct way to use Ember-Data to allow me use a model named “preferences” (plural). What I try is overriding application serializer:

typeForRoot: (root) ->
    return 'preferences' if root is 'preferences'
    @_super root

But when trying to .save() a model I get: Uncaught Error: No model was found for 'preference’ Looking closer I see the model’s constructor has a property ‘typeKey’ which is set to ‘preference’ (singular)

How can I disable this behavior for just this model?


To make it a little clearer maybe, I have in my route:

  model: (params) ->
    @store.find('preferences', params.preferences_id).then (p) ->
      console.log p.constructor.typeKey

And in the console I see ‘preference’ (single). I don’t understand why…



The only way I found to overcome my problem is overriding my store’s modelFor method:

Store = DS.Store.extend
  modelFor: (name) ->
    name = 'preferences' if name is 'preference'
    @_super name

I’m really not happy with this solution… though