Things I Couldn’t Figure Out Then Figured Out in Ruby On Rails — Part 1

I went to a Ruby hacknight the other night! There, I spent an hour and a half pair-debugging what turned out to be a painfully simple issue.

Once we were out of the woods, I asked my more experienced pair how to remember things that cause issues that I’ll need to remember in the future. My new hacker friend suggested creating a GitHub repo of issues I come across and ways to fix them. And with that suggestion, I decided to blob about them instead. J/k, I’ll repo them, too.

The issue I was having:

I needed to generate a migration: rails generate migration add_product_url_to_wishlists. But when I would type that into the terminal, I would get the following error:

The answer is definitely in this error message 🤦‍♀

Other behavior:

  • rails console produced the same error as the generate migration command.


  • rails server ran successfully.

I should mention that my view of the error message was not as it looks above. I have, before now, kept the terminal text large and more readable, which makes the error message broken up and scrollable and perhaps… less readable. I think I may have seen it if I’d looked at it as it’s pictured above. But who knows?!

Here’s what I did to try and fix it:

  • Made sure I was using the correct command to generate the migration. I was! Yay.
  • Stopped/started the server.
  • Ran the migration command with bundle exec.
  • Checked my other Rails projects to see if they were having errors. They were not.
  • Googled the hell out of the first couple lines of the error message, which lead me to:

— Comment out bootsnap in my Gemfile. Then uncomment it out.

— Add config.autoload_paths += %W(#{config.root}/lib) to the DressMe module in application.rb. Then delete that line.

Last ditch efforts, I:

  • Cleared the cache.
  • Bundled.
  • Bundle updated.

Lastest ditchest of efforts, I:

  • Restarted my computer.

After more googling with my pair, we:

  • Did all the things I had previously done, to make sure nothing had fallen through the cracks (they were baffled that rails server worked, but rails console did not. I’d already been baffled for awhile. They couldn’t out-baffle me).
  • Typed which ruby and which rails in the command line to see if we were using the correct versions for the project.
  • Stopped Spring with the stop spring command.
  • My pair pulled down the repo and we both checked out very old commits* (They got the same errors that I was getting).
  • More googling.
  • More cache clearing.
  • Naps.
  • Haircuts, showers, meals, and many moons.

Then we talked about the most recent additions I’d made to the app. I had added the auto-links gem a couple days before. It allows urls to be clickable (cute!). So, we did a bit more googling and error message reading with auto-links in mind. And then the answer revealed itself.

I braced myself.

The error was occurring because… the first few lines of my application.rb file looked like this:


Not like this:


Ohhhhh haha okay cool cool cool cool cool cool cool cool cool. The error was occurring because Ruby was trying to load the rails_autolink gem, which depended on Rails, which hadn’t been loaded yet.

This was fun. I learned things! And we solved the problem together!

  1. I learned that I’d like to keep my terminal text size a bit smaller, so I can read the whole error message at once without scrolling.
  2. I learned that reading the whole error message can help figure out the… error.
  3. I learned that the require order is important in application.rb.
  4. I learned how to clear my cache.
  5. I learned how to stop Spring, and why we use it or need it.

K bai!

*It doesn’t make sense to me that even with older commits we were getting the same errors, if I’d added this Gem and line of code only a few days before. If anyone has info about why that would be, please do tell.