Related Journal Entries
Creating your first custom Rails Generator can feel counter-productive at first, but with a little knowledge and experience, they can become a powerful tool to help you and your team save time.
I built an automated tool to inspect and document all of the available methods in a set of Ruby classes and modules in order to answer questions and provide data and insights that would help explore and recognize patterns and concepts with Rails Generators.
Almost everything done with Rails Generators happens using actions that streamline common tasks that would otherwise have to be performed with lower-level file system commands. Some of these actions are Rails-specific and some come from Thor. This post explores all of them as a unified collection.
While it’s difficult to identify one specific piece of Rails Generators that makes them special, Thor’s templating functionality makes a strong case for being that feature. We’re going to see how it works and the how Rails streamlines the process in order to see how handy templates can be.
Rails generators can help remove significant friction from the process of spinning up new ideas, but you don’t have to limit yourself to the included generators. You can also create custom generators as long as you’re familiar with the available APIs and know where the speed bumps are.