Skip to content

Instantly share code, notes, and snippets.

@HyShai
Created June 6, 2014 18:00
Show Gist options
  • Save HyShai/f92b8d3f0b8e3c60e072 to your computer and use it in GitHub Desktop.
Save HyShai/f92b8d3f0b8e3c60e072 to your computer and use it in GitHub Desktop.
//photo.hbs
/*snip*/
{{#each album in albums}}
{{#link-to 'albums.album' album}}
{{album.name}} //this loads properly
{{/link-to}}
{{/each}}
//routes/albums.js
model: function(params) {
var urlid = params.urlid.split('-')[1];
return this.store.find('album', urlid);
},
serialize: function(model){
//model.get('name') is undefined here - i assume bec it's not fully loaded
return { urlid: model.get('name') + '-' + model.get('id')};
//this return 'undefined-2'
//so it has the proper id
//but for some reason the model is missing the proper object/record
}
//models/photo.js
var Photo = Em.Model.extend({
name: Em.attr(),
url: Em.attr(),
albums: Em.hasMany("album", {key: 'albums'})
});
Photo.adapter = Ember.FixtureAdapter.create();
Photo.reopenClass({FIXTURES: [
{
id: 1,
name: "wassup",
url: "/assets/images/PROOF_01.jpg",
albums:[2,3]
} //etc.
]})
// models/album.js
var Album = Em.Model.extend({
name: Em.attr(),
photos: Em.hasMany("photo", {key:'photos'})
});
Album.adapter = Ember.FixtureAdapter.create();
Album.reopenClass({FIXTURES: [
{
id:1,
name:"anny",
photos:[2,3,4,8,10,14]
}//etc.
]})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment