Presenters, Decorators, and View Models
Explore how to simplify view logic in Rails applications by using the presenter pattern, decorators, and view models. Understand how these techniques wrap domain objects to handle view concerns effectively, reducing helper clutter and improving maintainability.
We'll cover the following...
Helpers conceptually solve the problem of executing code in a view pretty well. But, they cannot be scoped in any meaningful way (in other words, they are global to all views) and they become hard to manage when an app gets large.
When there are lots of helpers, it becomes hard to reuse them because we must navigate a potentially large list to see what’s available. This means it’s hard to avoid duplication and can even lead to name clashes. This is why most programming languages and frameworks have modules. Helpers really don’t work this way. Even ...