Last active
October 29, 2015 08:23
-
-
Save ksol/4b63a42272ffe8afbd1d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// adapters/comment.js | |
import ApplicationAdapter from './application'; | |
import Ember from 'ember'; | |
import UrlTemplates from "ember-data-url-templates"; | |
export default ApplicationAdapter.extend(UrlTemplates, { | |
urlTemplate: "{+host}/posts/{postId}/comments{/id}", | |
adapterContext: Ember.inject.service(), | |
urlSegments: { | |
postId() { | |
return this.get('adapterContext.post.id'); | |
}, | |
} | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Ember from 'ember'; | |
import config from './config/environment'; | |
var Router = Ember.Router.extend({ | |
location: config.locationType | |
}); | |
Router.map(function() { | |
this.resource('post', { path: 'posts/:post_id' }, function() { | |
this.resource('post.comments', {path: 'comments'}, function() { | |
// your routes here | |
}); | |
}); | |
}); | |
export default Router; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// routes/post/comments/index.js | |
import Ember from 'ember'; | |
export default Ember.Route.extend({ | |
model() { | |
let post = this.modelFor('post'); | |
this.get('adapterContext').setContext({post}); | |
return this.store.findAll("comment"); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment