Last active
August 29, 2015 14:02
-
-
Save validkeys/a04621d6ed00a3596511 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| PostsRoute = Ember.Route.extend | |
| model: (params) -> | |
| @store.find 'post', | |
| iteration: @modelFor('iteration').get('id') | |
| setupController: (controller, model) -> | |
| controller.set 'model', model | |
| controller.set 'iteration', @modelFor('iteration') | |
| `export default PostsRoute;` |
This file contains hidden or 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
| # the model here is the iteration | |
| PostsNewController = Ember.ObjectController.extend | |
| needs: ['posts'] | |
| postsController: Ember.computed.alias('controllers.posts') | |
| newPostBody: '' | |
| actions: | |
| newPost: -> | |
| store = @get('store') | |
| newPost = store.createRecord 'post', | |
| body: @get('newPostBody') | |
| iteration: @get('model') | |
| newPost.save().then (persistedRecord) => | |
| @get('postsController.model').pushObject(newPost) | |
| `export default PostsNewController;` |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment