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.
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
end
def last_order_date
view.time_ago_in_words last_order.created_at
end
def last_order_description
last_order.items.count + " items"
end
private
def last_order
@last_order ||= customer.orders.last
end
end
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.
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.
I initialize the presenter at the top of my view, rather than the controller.
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.