My favorite ideas here are the support for services, revised DB design defaults, and the distinction between reference data and transactional data.
Factories that build (in-memory) rather than create by default is a nice idea though I’m not sure how workable that’d be in practice (the article seems to underestimate how large a role the DB plays in rails apps in my experience).
Routing, JS: meh.
I would love to see this. I don’t know the specifics of how much work needs to be done.
It would simply not be Rails. Too much structure.
ActionResource would be totally superfluous. You don’t need a framework for everything, just write Ruby.
class Account < SimpleDelegator
attr_reader :customer, :view
def initialize(customer, view)
super(@customer = customer)
@view = view
last_order.items.count + " items"
@last_order ||= customer.orders.last
I initialize the presenter at the top of my view, rather than the controller.
<% account = Account.new(customer, self) %>
This does two things: 1, it’s explicitly clear where the presenter methods are coming from, and 2, it keeps the method signature of the presenter super light by using the existing view instance to access your helper methods.