lundi 28 septembre 2015

Ember Data Not Using Irregular Model Name

In my project, I have a inflector setup for a model with an irregular name, campus For some reason, after updating from Ember CLI 0.2.7 to Ember CLI 1.13.8, the inflector is no longer being applied to the model.

When trying to access the store, this.store.findRecord('campus', params['campus_id']), I get a warning

WARNING: Encountered "campus" in payload, but no model was found for model name "campu" (resolved model name using app@serializer:campus:.modelNameFromPayloadKey("campus"))

followed by this error

No model was found for 'campu' Error: No model was found for 'campu'

The return payload looks something like this

{
  campus: {
    id: 1,
    name: "Default Campus"
  },
  meta: {
    total: 1,
    page: 1
  }
}

and I have been using an initializer with previous success

import Ember from 'ember';

export function initialize(/* registry, application */) {
  var inflector = Ember.Inflector.inflector;
  inflector.irregular('campus', 'campuses');
}

export default {
  name: 'inflections',
  initialize: initialize
};

I've tried updating to the most recent version of Ember Data, 1.13.13, and updating the ember inflector to 1.9.3. I've also tried to move the irregular inflector into the model but am no closer to resolving the issue

I've also tried running the following code in the console before making a call to the store to see what the inflector is set to

var inflector = Ember.Inflector.inflector;
inflector.singularize('campus') // returns "campus"
inflector.pluralize('campus') // returns "campuses"

This issue is extremely frustrating since there doesn't seem to be anyway to resolve it.




Aucun commentaire:

Enregistrer un commentaire