Today I would like to talk about a component-based approach to writing views on Ruby on Rails applications using View Components.
What are View Components?
View Components is a new approach to programming views invented by GitHub. View Components are Ruby classes that can return HTML. This is a new vision of the presenter pattern. View Components is provided as a gem and it has detailed documentation. While writing this article the gem is being developed. But nowadays many people use this gem in production, including GitHub itself.
Let’s turn to the documentation itself for a better understanding of why View Components are needed, and when they should be used. …