Skip to content

Instantly share code, notes, and snippets.

@validkeys
Last active August 29, 2015 14:02
Show Gist options
  • Select an option

  • Save validkeys/a04621d6ed00a3596511 to your computer and use it in GitHub Desktop.

Select an option

Save validkeys/a04621d6ed00a3596511 to your computer and use it in GitHub Desktop.
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;`
# 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