Ember 3.4 and pluralize

Hi there,

Feels very good to work with ember again. :slight_smile:

I have to migrate a v2.13 application to Ember v3.4. I generated a new app based on 3.4 and no I try to add all artifacts step by step.

I have 2 Questions so far:

  1. Where or in which package is the old pluralize() method placed?
  2. Where I have to place my adapter classes now?

This is my old adapter:

import Ember from 'ember';
import DS from 'ember-data';

export default DS.RESTAdapter.extend({
    
    urlForFindAll(modelName/*, snapshot*/) {
        let baseUrl = this.buildURL();
        return baseUrl + '/rest/' + Ember.String.pluralize(modelName) + '.json';
    },
    
    urlForFindRecord(id, modelName/*, snapshot*/) {
        let baseUrl = this.buildURL();
        return baseUrl + '/rest/' + Ember.String.pluralize(modelName) + '/' + id + '.json';
    }
    
});

Best regards, Mario

Pluralize is now in ember-inflector so you can import like so:

import { pluralize } from 'ember-inflector';

and then use like:

  return baseUrl + '/rest/' + pluralize(modelName) + '.json';

As for where to put your adapter… I’m not on 3.4 yet but I’m pretty sure the adapter would still go in app/adapters/<adapter-name>.js unless you’re trying out module unification.

1 Like

Hi @dknutsen,

Very thanks for the import. After create a new app in 3.4 there was no adapter directory in my app directory. Therefore my question about the right place :slight_smile:

Mario

Ah yeah that’s probably not a default directory but it should still be right. You could always do an ember g adapter <adapter name> and see where it puts that to be safe.

Ah… very good idea. :slight_smile: Thanks …

Mario

For your further use cases of searching for ES6 imports:

Wow … many thanks for these links. Very helpful.

Best regards, Mario