Skip to Content

Save Time with Custom Rails Generators

Learn to create time-saving reliable custom generators quickly and efficiently.

It's time to quit the copy-paste-search-replace dance.

Duplicate an existing file. Then duplicate the corresponding test file. Open them in your editor. Search and replace throughout both files. Manually update or delete a few more things.

An illustration of someone frantically typing with keys flying off the keyboard and a coffee mug spilled on their desk.

Run the tests. Track down spots the search and replace didn't catch. Fix those issues, and run the tests again. Then you can get back to the real work.

That's no way to do things, and yet, we've all done it far too often.


You already apply and re-use basic patterns on a regular basis. You're just doing it the hard way—either because you didn't know or because you believed custom generators required more effort than they're worth.

Believe it or not, with a little insight, you can effortlessly create well-tested, reliable, and easy-to-use generators that save time—no rocket science involved. And when you create a custom generator, it doesn't just save time for you but for your entire team. Over. And over. And over again.

Every single Rails project already provides all of the tools to build custom generators. With a little guidance, you can use them just as effortlessly as every other part of Rails.

An illustration of someone leaning back in their chair and completely relaxed at their desk computer.

Once you see how custom generators can turn those tedious and repetitive ten-minute distractions into ten-second commands, you'll never look back.

How much time could you save yourself and your teammates?

How many copy/paste/search/replace tasks could you automate once and for all?

This book is an invaluable asset if you’re hoping to dive deeper into saving your team headaches & time, while keeping common development tasks better organized, tested and maintained for the long haul.
Photo of Kasper Timm Hansen
Kasper Timm Hansen Ruby/Rails Consultant Rails core 2016-2022

What does it cover?

Frictionless Generators takes a holistic approach to help you see how to efficiently create and test custom Rails Generators so you and your team can save time.

The Book

An illustration of a stop watch illustrating the amount of time saved.

Think of it as a guide for saving time that just happens to use custom Rails Generators as the methodology. We'll cover all of the key API's and tools for creating generators while also avoiding getting stuck in the weeds or creating generators nobody will ever use.

The book provides over 150 pages of pragmatic tips, tactics, and code samples to help you avoid speed bumps and get right into creating your own generators. But it's not just about learning how to create them. It's about learning when to not create one. It's about recognizing when and how to customize an existing generator so you don't reinvent the wheel.

Ready to start saving time? Ready to start saving time?

Get two free quick reference sheets and follow along with a short email course to demystify custom generators so you can create them quickly and efficiently. Skip the copy/paste/search/replace dance, and learn how save time with custom Rails generators.

No-nonsense, one-click unsubscribes.

Set aside any pre-conceived notions you may have about creating custom generators in Rails, and you'll add one more powerful tool to that tool belt of yours. And you'll waste less time on the tedious stuff so you can spend it on the high-value work you do.

Example pages from the PDF version of the book.
I learned a lot about a topic that I should know more about because good grief how much time have I spent copying, pasting, and changing Service Object files or spec files.
Photo of Jason Garber
Jason Garber Developer Author of “HTML5 with CSS3”

Chapters & Topics

  • Save Time & Reduce Tedium
    • Ensuring Generators are Net Time-savers
    • Identifying Generator Opportunities
    • Generating More than Code
    • Leveraging Tiny Generators
  • Generate the Big Picture
    • Understanding Thor's Role
    • The Generator Generator is an Accelerant
    • Generating Your First Generator
    • The Elements & Structure of Generators
    • Templates, Sources, and Destinations
    • Actions & Inflections
    • The Command Line & Documentation
    • Arguments, Options, and Interactivity
    • Parent Class Options & Inheritance
  • Arguments & Options
    • Knowing the Differences and Similarities
    • Defining, Passing, and Accessing
    • Types & Validation
    • Usage, Help, and Documentation
    • Judicious Arguments and Options
    • Your Generator's First Arguments
  • Usability & Interactivity
    • Providing Helpful Documentation
    • Communicating Errors & Success
    • Collecting Values with Prompts
    • Printing Results & Data
    • Adding Custom Error Handling
    • Making Your Generator Easy to Use
  • Leveraging Templates & Testing
    • The Magic & Power of Templates
    • Navigating Sources & Destinations
    • Writing Clean ERb in Templates
    • Using Rails Inflections
    • Supercharging Templates with Directories
    • JavaScript & Migration Templates
    • Automated Testing & Generators
    • Efficient Manual Testing
    • Dedicated Assertions & Helpers
    • Upgrading Your Own Generator
  • Creating & Modifying Files
    • Creating without Templates
    • Creating/Updating Common Rails Files
    • Prepending, Appending, and Inserting Text
    • Managing Indentation & Whitespace
    • Quoting Strings in ERb
    • Commenting/Uncommenting in Ruby Files
    • Inline Global Substitutions
    • Deleting Files & Directories
  • Utilities & System Commands
    • Running System Commands Directly
    • Running Ruby Commands Directly
    • Safely Navigating Directories
    • Version Control with Built-in Git Actions
    • Grab Bag of Extra Utilities
  • Extending & Customizing
    • Using ActiveRecord Introspection
    • Calling Other Generators
    • Overriding Generator Templates
    • Extending the Built-in Generators
    • Hooking Generators Together
  • Quick Reference
    • One-page Actions & Configuration Reference
    • One-page Values & Inflections Reference
  • Cheat Sheets (Premium Version)
    • Generators Cheat Sheet
    • Generator Testing Cheat Sheet
    • Generator Templates Cheat Sheet
    • Generator Command Line Cheat Sheet
  • Example Generators (Premium Version)
    • Variety of Ready-to-Use Generators
    • Use Directly or as Inspiration
    • Learn from Working Code Examples
…reading the book made me realise that I should just make a generator for this simple, repetitive task and save myself (and the team) time in the future.

Quick Reference and “Cheat” Sheets

For any resource to save time, it's not enough to just be a book. Books make for good trail guides, but paging back through a back to look up the name for that one method chips away at your time savings. Books are great, but the tidal wave of new knowledge can be more overwhelming than helpful at times.

That's why Frictionless Generators isn't just a book. It's truly designed to help you save time, and it includes quick reference and cheat sheets for those times when swimming back through the table of contents isn't fast enough.

Example thumbnail images of the Cheat Sheets & Quick Reference Sheets
…I really enjoyed it and learned a couple of things about generators that I didn’t know before. The first part was also a great source of inspiration on the type of generators we could build.
Photo of Benedikt Deicke
Benedikt Deicke CTO & Co-founder Userlist
An illustration of generator where templates go in and completed files come out.

Example Generators

In addition to the standard guidance, Frictionless Generators will also include a collection of pre-built generators for common scenarios. They can serve as well-documented examples and inspiration to learn from, or you can use them directly in your own projects. Use them as is or extend them for your unique needs.

  • Specialized Object Patterns

    Quickly create various types of objects for modeling your application's logic with consistent, predictable, and well-tested patterns.

    • Value Objects
    • Query Objects
    • Form Objects
    • Policy Objects
    • Collection Objects
    • Singletons
    • Data/Struct
    • Presenters
    • Decorators
  • Upgraded Rails Generators

    Examples of enhancing and modifying the existing generators to safely layer in additional functionality.

    • Partials & Helpers
    • Generators
    • Overriden Templates
  • Scripts & Automation

    Leverage generators to spin up skeletons for other types of specialized scripts or automation.

    • Shell Scripts
    • Bin Scripts
    • Rake Tasks
    • Rails Commands
    • CSV & JSON Reports
  • Documentation & Readme Updates

    Streamline the process of spinning up elements of documentation or reports related to the codebase.

    • Vendors
    • Dependencies
    • Reports
    • Changelogs

They're all written and documented to be read and easy to follow while also including relevant tests. They cover a wide variety of scenarios to help illustrate how custom generators can be used in a variety of ways for any kind of text files—not just generating code.

I liked it and would recommend it. Your writing style is great, very to-the-point and clear. The book is well organized and had several things I was not aware of being able to do
Photo of Dave Copeland
Dave Copeland Author of “Sustainable Web Development with Ruby on Rails”
Hello!

I’m Garrett, and I’ve been building Rails apps since 2007. Like most, I frequently used the built-in Rails generators because they save time and help skip the tedious work, but despite knowing how helpful they were, I never dug into custom generators.

One day, though, I was done with the tedium and decided to I needed a custom generator. Unfortunately, the learning curve was too steep. It was going to be faster and more pragmatic to just keep on copying and pasting.

Finally, after a few abandoned attempts, I decided to dig in and figure it all out. It took some time and involved way too many mistakes. Eventually, though, it became easier, and custom generators have become another handy tool in my arsenal.

After that, I thought I could short-circuit that learning curve for others, and I wrote a blog post covering the basics of creating custom generators. Quite a few folks reached out to share how helpful it was, so I decided to go a step further and create “Frictionless Generators” to help reduce tedium for everyone.

I hope it saves you countless hours!

Garrett Photo of Garrett
…all your work on generators has kick-started something in my brain and given me options I had never considered.
Photo of Rob Whittaker
Rob Whittaker Director of Software Development Thoughtbot
Cover of Frictionless Generators

The Full Package

The best way to become an expert at creating custom generators.

  • The Book (PDF & ePub)
  • The Quick Reference Sheets
  • The "Cheat" Sheets
  • Sample Generators
49
Cover of Frictionless Generators

Just the Book

And nothing but the book. Well, the basic quick reference sheets are included to help save time as well.

  • The Book (PDF & ePub)
  • The Quick Reference Sheets
29
Or try it out first... Or try it out first...

Subscribe to the free email course with the free quick reference sheets for some practical advice and insights about getting started creating custom generators. You can also download the first two chapters to see a sample before purchasing.

No-nonsense, one-click unsubscribes.
This looks phenomenal! The book is great. The illustrations make it a lovely ‘digital object’.
Photo of Adam Keys
Adam Keys Engineering Manager Pingboard

Additional Questions

Who's it for? Do I need to know Ruby and Rails extensively?

If you're a Rails developer who wants to save time on tedious tasks but never quite made it over the initial learning curve creating your own generators, you'll likely appreciate this book.

If you're deeply experienced with building custom generators already, it likely won't cover significant new ground for you, but it may still help surface some opportunities you've previously missed out on with custom generators.

Is it available to purchase elsewhere?

Yes. PragProg carries it as well. So if you've built up a significant library with them, you can purchase a copy there instead.

Is there a sample to read before purchasing?

Definitely! You can download a PDF of the first two chapters.

How long is the book?

The book takes about two or three hours to read straight through. I've intentionally done my best to keep it short and actionable so you can start saving time as quickly as possible.

Do you offer bulk discounts?

Absolutely. I've discovered that custom generators can be a huge benefit for teams because they standardize frequent tasks and help reduce errors while also reducing the need for detailed documentation for some tasks.

If you're looking to buy multiple copies for your team, let me know, and I'll send you a coupon for 10% off 2-5 copies or 25% off more than 5 copies.

What's your refund policy?

If you don't feel like you've learned how to quickly and efficiently build custom generators that save you time, let me know within a couple weeks of purchasing, and I'll kick off a refund immediately. It can take around five days for the credit to show up.

If possible, I'd appreciate it if you could include some feedback about how the book didn't meet your expectations so I can make sure to update the site or clarify anything that may have been incorrect or misleading for others.

Can I learn anything new if I'm already very familiar with the built-in generators?

Absolutely. Using the built-in generators is a great start that will provide great context, but designing and building your own generators from scratch is a whole other story. You'll invariably learn more about the built-in generators, but the real focus in the book is about helping you learn the ins-and-outs so you can quickly create your own for anything you need.

Can you help me convince my boss to purchase?

You bet. Here's a draft of an email that you can adjust and send to your boss.

Purchase Request Letter

Dear Boss,

Our team wants to create better code in far less time using Rails Generators. By creating custom Rails generators efficiently, we’ll be able to codify our team’s patterns and automate creating new code in a highly-testable manner.

Rails custom generators save time in the long-run by enabling us to perform standard tasks much more quickly. And since custom generators are built into our Rails codebase and support automated testing, they’re easier to create and more reliable than standard shell scripts.

Even better, by codifying common patterns into generators, it’s easier for new or junior team members to make progress without needing assistance from any other team members. Not only does that save time, but it helps empower them to contribute sooner.

We know it can work, but there’s a bit of a learning curve. That’s why we are asking for you to invest in licenses to Frictionless Generators (https://generators.dev) by Garrett Dimon.

Garrett has written a book with a laser focus on leveraging custom generators to save time and reduce tedium. Paired with a set of quick reference sheets and sample generators, it’s a short read that can help us ship better code faster.

With the bulk discounts, it seems like a great investment to enhance our skills. You can visit the Frictionless Generators site to read more and purchase licenses for us: https://generators.dev.

Thanks for giving it some thought!

The Team

How can I ask a question not covered here?

Just send me an email. I'll usually get back to you the same day—if not sooner.

Ready to start saving time? Ready to start saving time?

Get two free quick reference sheets and follow along with a short email course to demystify custom generators so you can create them quickly and efficiently. Skip the copy/paste/search/replace dance, and learn how save time with custom Rails generators.

No-nonsense, one-click unsubscribes.