Problem routing ember and mirage


#1

Hi, I have created a model with name criteria

export default DS.Model.extend({
  age:DS.attr(),
  info:DS.attr(),
  demand: DS.belongsTo('demand'),
});

name of file criteria.js. but when i make in a router for example

return this.store.queryRecord('criteria', {filter: {demand: this.get('auth.currentUser.demand.id')}});

ember call mirage with the url GET /criteria?filter%5Bdemand%5D=1 and not with the name criterias GET /criteria?filter%5Bdemand%5D=1

why?

So I have a problem because in the config file i can not use criterias but criteria and is a error


#2

Does it work if you hardcoded a 1 in the filter? I think it has to do with this.get(...) returning a promise rather than a hard value.


#3

I think this might have to do with how Ember Inflector handles pluralizing the word criteria. (Both Ember-data and Mirage use Ember Inflector for pluralizing model names).

Technically, criteria and not criterias is the plural; the singular form is criterium (You have Latin to thank for this!)

So, either you stick with criteria for both the singular and plural form — or, you could change the name of your model and mirage factory to be criterium and then use the plural form in the appropriate places.

Hope this helps!