Conversation
|
Any blog posts about this? |
|
@gmkohler I'll dig around. I agree that it'd be nice to have a |
|
|
||
| ##### Why? | ||
| * Prevents existing controllers from becoming too busy | ||
| * Eases the use of ember-data |
There was a problem hiding this comment.
Is this because ember-data makes assumptions about being RESTful?
In some cases it's useful to have a separate domain model for a catering-order-cancellation because:
- this guarantees that the
catering-orderdoesn't need to be mutated accidentally, - you can create a cancellation without necessarily loading the
catering-orderin the store.
There are good patterns for action style routes in Ember, notably with ember-api-actions.
|
This seems to be entirely a conversation about using RESTful routes vs action style routes since both patterns allow definition of sensible domain models and that Ember works well with both styles. I feel neutral about RESTful vs action routing because in some cases a RESTful route is more useful and in some cases an action route describes the situation better. It'd be a shame to prevent ourselves from using the best tool for the job. |
|
If If it returns a a separate kind of resource then I think it often should be refactored the way you've suggested, e.g. if
Neither case should result in busy controllers. In both cases you should extract the bulk of the work out to interactors (or whatever your favorite word for the command pattern is).
As @binhums mentioned, ember-api-actions makes this pattern nice to use in Ember Data. |
|
I'm thinking more in terms of keeping that paths through an API straightforward and clean. For example, if you're going to end up with a domain model, Sure, member actions can be fine when the action is very simple such as the toggling of a field in the database on the related record ( === Perhaps "prefer named resources over member or collection routes` is what we want, but I do think this is important. |
Looks like an argument to favour pairing web api to the domain model which I'm down with.
Avoid and prefer seem more or less equivalent in this case given that I don't expect people to do this without good reason. I'd be down for merging if we remove the argument for Ember data being easier. |
|
Here's a relevant article: http://jeromedalbert.com/how-dhh-organizes-his-rails-controllers/. I like that |
Please leave open until at least Wednesday, June 14th.