Ember Data associations return null for all fields, even though the data is there


#1

I’m currently trying to get a specific field from a belongsTo association on one of my models. My code looks something like this

fieldsRequired = this.content.get('state.fieldsRequired');

This returns null. However, if I dump the state object and look at the _data.attributes object, fieldsRequired has the data that is in the database. Furthermore, I can place it in my templates and everything works just fine.

It seems that this is the case for all associations. Any integer/string fields are set to null, and any boolean fields are set to false, but only when I try to perform a direct get(). Has anyone else experienced this issue?


#2

I have some similar issues with sideloaded data. I downgraded ember-data-source to 0.0.5 and everything went back to normal (in case you are using ember-rails gem)


#3

I actually figured out the issue, it was kind of a misunderstanding of computed properties on my part. Basically, when I was trying to get the null fields they actually WERE null, since it was computing the properties BEFORE the data was loaded. So, part of what I needed to do was set it up to watch the proper fields so it would update when the data was actually loaded.