Namespace Support For Ember Data Models


#1

Support Model Namespacing Issue

A model with namespace in Rails has this default interface

GET /namespace_name/model_name
POST /namespace_name/model_name

Currently ActiveModel::Serializers serializes a model with namespace without mentioning the namespace (which makes sense)

GET /namespace_name/model_name
{
  "model_names": []
}

The motivation is that most domains can only be represented via namespaces in a meaningful way. And sometimes they can’t be represented without namespaces.

For example, FirstNamespace::FirstKind and SecondNamespace::FirstKind. Assuming these models are different it’s currently not straight forward to implement this in Ember Data (a patch is provided by @davydotcom in specified issue)

A possible implementation would be

App.FirstNamespace = Ember.Namespace.create();
App.FirstNamespace.FirstKind = DS.Model.extend();

Build /first_namespace/first_kind url for this model

And if /first_namespace/first_kind returns

{
   "first_kinds": []
}

Assume that this is representation of App.FirstNamespace.FirstKind.