Fixing ActiveModelSerializer in Ember-Data
Just a quickie... I need to write a longer post after the significant help I got yesterday from Ember dude Eric Berry.But I did manage to figure out using the DS.ActiveModelSerializer. There is an entry in the Transition Doc of Ember Data talking about using underscores.
It seems the DS.RESTAdapter now defaults to expecting camelCase'd class names. And the DS.ActiveModelSerializer does not fix this (thereby NOT working with Rails' ActiveModelSerializer out of the box - well done guys!). Also, the aforementioned document section is completely wrong.
This is what you need to do somewhere (I put it in store.js) to get it to work with Rails' ActiveModelSerializer:
App.ApplicationSerializer = DS.RESTSerializer.extend({ typeForRoot: function(root) { var camelized = Ember.String.camelize(root); var s = Ember.String.singularize(camelized);
var deCs = Ember.String.decamelize(s); // console.log(root + "; " + camelized + "; " + s + "; " + deCs); return deCs; } });
I still need those nasty 'key:' entries on the rails side though to make associations work. But I am guessing it is something similar causing the problem.
We're all in this together.