Quantcast
Channel: Ember.JS - Latest topics
Viewing all articles
Browse latest Browse all 4828

Issue with belongsTo relationship

$
0
0

@jfschaff wrote:

Hi, I have a model:

// app/models/expert.js

export default DS.Model.extend({

  ...

  user: DS.belongsTo('user');

  ...

});

and an API that gives JSON data of the form:

# /experts/07ecb03699efe504

{
  "id": "07ecb03699efe504",
  ...
  "user": 54,
  ...
}

user is another model that works well and correspond to API endpoints /users/ and /users/<id>/. So the relationship is just given by the id of the model. This is what I do for all my models and works well in general.

But with this particular model (expert), the user object is not loaded when used (for instance in a template) and all expert.user, expert.get('user') and expert.get('user.id') are undefined (assuming expert is an instance of the expert model)… I get no error in the console so everything looks fine, but the data is not loaded and no request goes out to the /users/54 endpoint…

When I inspect the relationship with ember inspector, I have something like user: <(unknown):ember420> and if I send it to the console I get:

Seems like a bug to me, but not sure…

How could I investigate it further?

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 4828

Trending Articles