getoutreach / epf

A framework for keeping your Ember.js apps in sync.
http://epf.io
MIT License
369 stars 33 forks source link

Can't have belongsTo relation to work... #146

Closed fiftoine closed 9 years ago

fiftoine commented 9 years ago

Hi,

Considering the model :

App.Bar = Ep.Model.extend();
App.Foo = Ep.Model.extend({
    name: Ep.attr('string')
})
App.Bar.reopen({
    name: Ep.attr('string'),
    foo:Ep.belongsTo(App.Foo)
})

When the server responds with

{"bar":{"id":1, "name":"my bar","foo_id":1 }}

to

this.session.query(App.Bar)

then bar.foo is empty, even if the property name of foo is observed... I suppose a LazyModel instance should be set to foo...

What am I doing wrong? Thanks in advance

fiftoine commented 9 years ago

Actually, EPF looks for a "foo" property in the hash but how can I make it to look for "foo_id"? I tried setting typeKey property in foo property in the BarSerializer but it's not using it... Should I implement a complete deserialize method or is there some property to set ?

fiftoine commented 9 years ago

Ok found it!!! Seting the key property on the foo properties on the BarSerializer to "foo_id" did the trick.

Hope it can help someone though.