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

Can't consume json with relationship

$
0
0

@DylanGuedes wrote:

Hello,

I have a json server (in phoenix/elixir) and it generates this json:

{
sections: [
{
topics: [
{
title: "Botafogo melhor time",
subtitle: "quem concorda faz barulho",
id: 4,
content: "BOTAFOGO 10X0 NO FLAMENGO CTZ"
},
{
title: "Real vs Barça",
subtitle: "vai ser mt loko",
id: 2,
content: "acho que o benzema vai mete 10x0 lol"
},
{
title: "Real vs Barça",
subtitle: "vai ser mt loko",
id: 3,
content: "acho que o benzema vai mete 10x0 lol"
},
{
title: "anewtopic",
subtitle: "lolnicetopic",
id: 1,
content: "lolnicecontent"
}
],
name: "nice sectionlol",
id: 1,
description: "nice section"
},
{
topics: [ ],
name: "novatentativa",
id: 2,
description: "tentativa"
},
{
topics: [
{
title: "adoro esse forum",
subtitle: "nao acham",
id: 6,
content: "nao concordam???"
}
],
name: "novatentativa",
id: 3,
description: "tentativa"
},
{
topics: [
{
title: "Real madrid rula",
subtitle: "mas cr7 é lixo",
id: 5,
content: "vcs nao acham?? rsrsrs"
}
],
name: "novatentativa",
id: 4,
description: "tentativa"
},
{
topics: [ ],
name: "novatentativa",
id: 5,
description: "tentativa"
},
{
topics: [ ],
name: "novatentativa",
id: 6,
description: "tentativa"
},
{
topics: [
{
title: "eahseuhsaei",
subtitle: "hehaeheuae",
id: 7,
content: "ehuaihueae"
}
],
name: "Geralzão",
id: 7,
description: "descriassasae"
}
]
}

To explain: a section has topics, and a topic belongs to a section.

This is my topic model definition:

import DS from 'ember-data';
export default DS.Model.extend({
  section: belongsTo('section'),
});

And, my section model:

import DS from 'ember-data';
export default DS.Model.extend({
  topics: hasMany('topic'),
});

Error: sections.index Assertion Failed: Passing classes to store methods has been removed. Please pass a dasherized string instead of undefined Error: Assertion Failed: Passing classes to store methods has been removed. Please pass a dasherized string instead of undefined at new Error (native)

My router:

export default Ember.Route.extend({
  model() {
    return Ember.RSVP.hash({
      sections: this.store.findAll('section')
    });
  });
});

any tips? ;ṕ

Posts: 3

Participants: 2

Read full topic


Viewing all articles
Browse latest Browse all 4828

Trending Articles