Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mischaracterizes resources where the name is a singular ending in 's' #60

Closed
dbinetti opened this issue Jan 23, 2015 · 3 comments
Closed

Comments

@dbinetti
Copy link

I'm not sure if this is a bug or design decision, but I am unable to resolve a specific issues regarding a resource where the singular version of the name ends in 's': specifically, i'm trying to map the resource 'chorus', which creates all sort of issues: EDA seems to look for the singular version of the endpoint, but the controller then thinks it's an object and not an array, something else starts looking for 'choru' (dropped s) and all sorts of other unpleasantries.

Obviously I can change my endpoint name to whatever on the DRF side, but presumably the point of this adapter is to serve as the gateway without having to touch DRF. Anyway, would appreciate some guidance or simply a 'yep, that's the design'.

FWIW, I come down on the 'name all collections singular' side of that particular religious war, but am not so zealous as to do what I have to do to make things work... :-)

@benkonrath
Copy link
Collaborator

EDA uses this function to create the paths (endpoints):

pathForType: function(type) {
  var dasherized = Ember.String.dasherize(type);
  return Ember.String.pluralize(dasherized);
},

You can override this in your own app if you don't like this default and make everything singular. Here's a link that should help:

http://emberjs.com/guides/models/customizing-adapters/#toc_path-customization

In your case, you might have to also tell the inflector about how to deal with the word 'chorus' for singular / pluralization. Here's the a link to the docs that should help with this one:

http://emberjs.com/guides/models/the-rest-adapter/#toc_pluralization-customization

Do these suggestions / pointers solve your problem?

@dbinetti
Copy link
Author

Thank you! I'll need to better understand how to override using the custom adapters, but that isn't a bug...

@benkonrath
Copy link
Collaborator

You can run this ember-cli command to generate an adapter that you can override:

ember generate drf-adapter application

This is documented here:

http://dustinfarris.com/ember-django-adapter/extending/

I'm glad I could help you out on this one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants