Rails Components: More Installer Over Library
After covering what rails components are and why they need to be first class citizens in the rails ecosystem, in the next few posts I'm going to share my vision for how they could work (and for the most part, how they currently work in the first comp...
code.avi.nyc6 min read
Here is my perspective on this:
Why:
Thus a generator is the best option here. I want to generate the components that I need. If I don't need any customization, they will remain under
app/viewssomewhere. But if I need to change something I can easily do it.But if this were a library, it is hard to change just a bit of a component from the HTML perspective, especially if that is partial. It is hard to inherit it and add an extra
ariaattribute.Someone might say: then let's make the components flexible so that everything that is needed to be added can be added via locals/variables. But that will mean a very complex code.
As an example: authentication-zero. It is a great choice to make authentication a generator because almost every time, something specific needs to be changed with authentication. In case of devise I almost always generate the views and refactor them with a different HTML code.