Skip to content

Instantly share code, notes, and snippets.

@kueda
Created May 14, 2013 23:22
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save kueda/5580524 to your computer and use it in GitHub Desktop.
Save kueda/5580524 to your computer and use it in GitHub Desktop.
App.TaxonTileController = Ember.ObjectController.extend({
defaultPhotoUrl: function() {
var guideTaxon = this.get('content')
var photos = guideTaxon.get('guidePhotos')
var photo = photos ? photos.get('lastObject') : null
var url = photo ? photo.get('url') : 'http://www.inaturalist.org/images/animals.jpg'
if (photo) {
console.log("[DEBUG] photo._data.attributes: ", photo._data.attributes) // this is an empty object
}
return url
}.property('content.defaultPhotoUrl')
})
DS.RESTAdapter.configure("plurals", { taxon: "taxa", guide_taxon: 'guide_taxa' });
App.Store = DS.Store.extend({revision: 12})
App.Guide = DS.Model.extend({
title: DS.attr('string'),
description: DS.attr('string'),
guide_taxa: DS.hasMany('App.GuideTaxon')
})
App.GuideTaxon = DS.Model.extend({
name: DS.attr('string'),
displayName: DS.attr('string'),
guide: DS.belongsTo('App.Guide'),
guidePhotos: DS.hasMany('App.GuidePhoto')
// range: DS.belongsTo('App.Range'),
// sections: DS.hasMany('App.Section')
})
App.GuidePhoto = DS.Model.extend({
title: DS.attr('string'),
description: DS.attr('string'),
url: DS.attr('string'),
guideTaxon: DS.belongsTo('App.GuideTaxon')
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment