Generating Rails Generator Commands
Rails generators are awesome, and one of the many things I love about Rails, however sometimes even generators aren’t DRY enough. I’ve found myself on more than one occasion writing out the same exact generator commands over and over.
So today I wrote a quick script that will read the Models of a current Rails app, and generate an executable of generator commands along with all of the attributes and types.
I just used this script to generate resource and jbuilder code during a refactor of code and upgrade to Rails 4. Just change the constants at the top of the script to customize the generator commands generated.
Now that’s what I call DRY!