Service objects with CRUD interface
Uniform CRUD interface to all of your domain objects (models and services) and why this is useful. Get rid of if @model.save redirect_to
in your controllers http://undefined-reference.org/2015/12/05/services-with-crud-interface-usage.html
Comments
I like how in APIs you can make things even more DRY by raising validation errors and catching them globally (when rendering templates you always render a different one for different actions, but in APIs you always return validation errors as JSON in the same way).
I don’t really like the idea of making serivce object responsible for more than one action.
Alexander, it doesn’t have to violate SRP. You can create different objects for different actions and call them from the one proxy-service with crud interface. I just used rather simple example. The whole idea here is a single interface to domain objects which is convenient to use in controllers.
Post a comment