guides-source
guides-source copied to clipboard
Ember Data Model Nesting/Namespacing
One thing I stumbled upon when trying Ember Data is the seemingly lack of support for namespaced data models. Running ember generate model user/google generates a UserGoogle model in app/models/user/google.js.
However, the issue is that Ember Data itself does not seem to support namespaced model names. I assume the JSON API spec does not allow / in the resource type, so Ember Data assumes no model will ever be namespaced. When trying to do Ember Data operations like finding a specific resource, Ember Data seems to error out trying to load the class.
When using the same code but doing ember generate model userGoogle, the code works. It generates files like app/models/user-google.js.
I think a note should be added to the guides if there is indeed a limitation with namespaced Ember Data model names. I assumed that model namespaces would be supported because routes and components support namespaces.
@bluk we've been using namespaced models for years, however due to specifics of backend we need to specify url almost for each and every model. Hence I guess it may be smth related to automatic url construction mechanism of Ember Data adapters