Skip to content

Instantly share code, notes, and snippets.

@mwieher
Created February 27, 2014 19:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mwieher/9257159 to your computer and use it in GitHub Desktop.
Save mwieher/9257159 to your computer and use it in GitHub Desktop.
App.House = DS.Model.extend({
doors: DS.hasMany('door');
});
App.Door = DS.Model.extend({
index: DS.attr(); //this doors position in the list of Many doors
house: DS.belongsTo('house');
});
App.DoorController = Ember.ObjectController.extend({
previous_door_id: function() {
var model = this.get('model');
var index = model.get('index');
var house = model.get('house');
var doors = house.get('doors');
var previous_door = doors[index-1];
return previous_door.id;
}.property('id')
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment