What Rails Documentation Doesn’t Tell You: 3 Crucial Developer Challenges

What Rails Documentation Doesn’t Tell You: 3 Crucial Developer Challenges
GUILHERME ANDRADE
November 3, 2024
/
Tutorials

What Rails Documentation Doesn’t Tell You.

Rails, as a web framework, is great for getting a web app off the ground quickly. Whether it's a personal project or the early stages of a startup, you’re almost guaranteed to find everything you need in its core libraries to ship something fast. But as your app grows and the domain complexity starts to pile on, you might notice something: the Rails documentation doesn't always have the answers for the kinds of problems you're now dealing with.

the Rails documentation doesn't always have the answers for the kinds of problems you're now dealing with.

As your project matures, the straightforward guidance that Rails offers starts to fade, and you’re left with questions that don’t have clear answers in the docs. That’s when friction starts to creep in. You’ll find yourself writing code that doesn’t quite fit into the standard Rails patterns, or relying on libraries that feel like they're just bolted on. Worse yet, you might end up with code that's difficult to maintain, riddled with performance issues, or just plain buggy. And suddenly, that "magic" that made Rails so appealing starts to feel like a burden.

At this stage, the issues you’ll run into usually fall into one or more of these three categories:

  • Code that requires more than the core Rails libraries: As your app grows, you often need features that the framework doesn’t provide out of the box, leading you to patchwork external solutions.
  • Code that becomes too complex for the simple MVC architecture: The default Rails patterns start to break down as you introduce more complex business logic, making your codebase harder to maintain.
  • Code that fails due to the use of Rails' own patterns: Using certain Rails conventions can lead to performance bottlenecks, bugs, or maintenance nightmares, and sometimes the framework’s magic becomes the problem instead of the solution.

In this article, I’m not here to talk about the quick-fix Rails solutions for hobby projects. I’m talking to the developers who’ve spent months (maybe years) working on growing Rails apps—developers who have hit the same roadblocks I have, and who have searched the docs for answers that aren’t there. If you’ve been struggling with finding a path through some of Rails' hidden complexities, stick with me. I’m going to walk you through three common challenges that the documentation just doesn’t cover, and what you can do to navigate them without tearing your hair out.

But before we dive into the specifics, let’s start with some foundational principles that will help you reduce the friction in these situations.

The Base Principles.

These don't apply to the development of Rails apps alone, but are particularly relevant in Rails in my opinion, because of the problems we mentioned earlier.

For that reason, keep these in mind:

1. Do keep it stupid simple (KISS)

One of the biggest downfalls of a developer is abstracting too much too early, foreseeing problems that may never be relevant for the future of the company. I have been too many times guilty of doing this myself, and worked long enough to see how damaging it could be in the long run.

2. Remember that Simplicity is an antonym of Complexity, but is not synonyms with Easy.

When an organisation strives to “keep things simple”, too often are arguments construed in favour justifying a particular solution by calling it “simple”, when the author of the argument actually means “easy”. By this I mean that, in order for you to consider something as the “Simplest solution”, your considerations should not revolve around the time it takes to develop it, but around the total time and maintenance costs of the feature. Not to say that a solution can’t be easy and simple, on the contrary, that’s the ideal scenario, and by taking simple solutions you’ll guarantee than in the future you’ll have an easier time find the simple solution.

3. Remember that Consistency (almost) always trumps correctness.

Don’t go against existing patterns if you believe you’ve found a better one, unless you can entirely replace the existing pattern, otherwise you’ll end up with 2 patterns, and where there’s room for 2 patterns that do the same thing, there’s likely room for a third, and so on.

Always remember that following patterns will make your code better and easier to maintain than introducing a new pattern that others will need to learn.

[To be continued]