Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Ember and Rails

Steve Kinney
December 17, 2014
77

Ember and Rails

Steve Kinney

December 17, 2014
Tweet

Transcript

  1. Ember and Rails both take MVC pretty seriously. (That said,

    they both have a very different take on it.)
  2. Let's say you visit /notes/1 and then you visit /notes/2.

    It's the same controller, but the route has switched out the model.
  3. // models/post.js export default DS.Model.extend({ title: DS.attr('string'), body: DS.attr('text'), comments:

    DS.hasMany('comments') }); // models/comment.js export default DS.Model.extend({ comment: DS.attr('string'), post: DS.belongsTo('post') });
  4. GET /comments?ids[]=56&ids[]=58 { "comments": [ { "id": "56", "message": "Whatever",

    "post": "12" }, { "id": "58", "message": "Something", "post": "12" } ] }
  5. What just happened? Ember Data sent off two AJAX requests

    to Rails in order to build the relation in the browser.