Andy from Webcrunch

Subscribe for email updates:

Portrait of Andy Leverenz
Andy Leverenz

April 2, 2024

Last updated April 3, 2024

Avoid these 9 mistakes I made when learning Ruby on Rails

Are you learning Ruby on Rails? If you’re like me, you’ve probably made many mistakes while using the framework.

I still make these mistakes today, but as I’ve learned more about the framework, it’s more obvious why they are common among developers looking to build an app and make something work.

Once your ideas come to life, you realize you might have sometimes coded yourself into corners. I hope this list of mistakes will help you navigate your learning process.

1. Skipping the Basics

When I started, I dove into complex topics without mastering the fundamentals of MVC architecture, routing, and ActiveRecord.

Let me tell you that if modeling in ActiveRecord is still fuzzy, you don’t need to worry about all the Hotwire goodies just yet.

Do you know what a database index is and why you’d need one?

Do you understand polymorphism and its benefits?

Can you architect relationships without struggling to grasp how they behave?
Can you code a full MVC pattern without using the built-in rails generators?

I couldn’t do any of this when I started.

Still, with repetition and submerging myself in a problem worth solving (the app I wanted to build at the time), I could slowly connect the pieces and understand how the framework works using conventions.

2. Ignoring Documentation

I’ve seen many newcomers overlook the official Rails documentation, a goldmine of information.

I know reading documentation is dull, but everything is there for the most part.

Relying solely on tutorials or Stack Overflow can lead to incomplete understanding.

My content isn’t perfect, but I hope it’s helpful. When in doubt, I’ve found that reading the docs and the source code will slowly make things stick rather than asking blindly in forums or social platforms.

As you progress, you’ll notice that even the docs aren’t up to date, so you need to go one step further and look at Rails's source code to decipher certain features or conventions or ask more experienced devs to slap some sense into you.

3. Poor Git Practices:

Git is foundational. Before doing much with Rails, you should grasp the basics of git. Doing so will make your life easier as you begin to build. You need to know git to put an app in a production environment, so there’s that.

Failing to use version control properly, such as committing too infrequently, not writing clear commit messages, or neglecting to branch correctly, can cause confusion and mistakes down the line, especially in a team setting.

I use git on all projects. The commit messages are pure shit most of the time. If I’m working on a team, I try to draft up some structure around the change and its reasons.

4. Not testing the crucial parts of your code

Neglecting to write tests for core logic in your app can result in buggy software and make future updates and modifications difficult.

If you’re like me, you commonly feel it feels counterintuitive to spend time on tests, but I’ve learned firsthand how they ultimately save you time. After all, time is money.

Some devs go off the deep end on tests and overdo it. I don’t buy into the Test Driven Development approach, but some do, and that’s okay!

Depending on where you are in your app’s journey, I believe that just enough tests are all you need.

You want to make sure the functionality of your app's core logic is working. The same probably applies to billing logic so that you can get paid. Tests help with this dramatically.

5. Copying and Pasting Code

While it's tempting to copy and paste code from online resources, it's essential to understand what the heck each line does.

Blindly copying code without comprehension can lead to errors and hinder learning. In my early days, out of desperation, I often did this.

Many want to learn to code while living in tutorial hell. They never fully grasp how or why things work the way they do.

The same is true for using AI tools. Yes, it’s faster, more efficient, and damn impressive, but you lose the cognitive abilities as a developer know-how of how to navigate the logic.

6. Overlooking Security Concerns

Security is crucial in web development. Ignoring basic security practices like parameter sanitization, authentication, and authorization can leave your application vulnerable to attacks. I’d take conventional routes here and not reinvent the wheel. Security should always be kept in mind.

7. Ignoring Performance

Failing to optimize code and database queries can lead to slow-loading pages and a poor user experience. Learning how to identify and fix performance bottlenecks is essential. As your application grows, you’ll run into those pesky n+1 queries and missing indexes and get a crash course on the caching features of Rails, among many others.

8. Not Asking for Help

Many beginners hesitate to ask for help when they're stuck. Utilizing resources like forums, online communities, and mentorship can accelerate learning and prevent frustration.

9. Having an ambitious enough goal

When I learned Rails, I approached it with a big goal. I recommend you do the same. Pick something that seems near impossible if you can.

For me, my goal was never to learn Rails for Rails sake.

Instead, I wanted to build a SaaS design tutorial platform. Doing so meant I needed to learn the framework inside and out. Because of this goal (which I finally met but eventually sunset), I didn’t give up too soon.

It was a shit show.

I learned about every possible error before even trying to deploy the app.

Along the way, I filmed myself struggling with the “Let’s Build’s” you see on today. Those blog posts and videos, in addition to pure grit, finally got me to learn and understand the framework enough to be deadly.

Today, I’m still learning. I still run into errors and ship crappy code.

The difference is having more wisdom and a consistent drive to want to build cool apps and teach others.

Practice makes perfect, as they say. I’m far from ideal!

Link this article
Est. reading time: 5 minutes
Stats: 113 views



Part of the Ruby on Rails collection