1
votes

In previous versions of Ember, I used a singular PostController to manage new/show and edit views.

But now with the separation of controllers and routes and the convention of using post.new/post.edit/post controllers, I'm not sure what the convention for sharing the logic across views. Bear in mind my edit/new routes aren't nested inside the posts route because the outlets aren't nested so I can't put the logic in a parent route.

  • Do I override the controller in the route and use my old singular controller?
  • Do I use {{with controllers.post}} block inside the handlebars template?
  • Do I use a shared mixin between PostNewRoute/PostEditRoute and PostNewController/PostEditController?
  • Do I inherit PostEditController from PostNewController?
  • Wrap all the post routes inside a route who's template is simply {{outlet}} so I can inherit shared events?
  • Something else I've missed?

I doubt there's a proper convention for this yet, but I'd like to hear how other people are doing it?

1

1 Answers

0
votes

Use the render helper:

https://gist.github.com/dagda1/4758119

Then you can use the model hook in the router to either create the record or retrive it in the route:

https://gist.github.com/dagda1/4758144