Chapter 10. Debugging Rails Applications

Introduction

Bugs are a fact of life for all software projects. A bug is a defect in a software system where the outcome of running the software is not what was expected, or perhaps, not what your client expects. Bugs can be as blatant as mistyped syntax, or they can be very elusive and seemingly impossible to track down. Bugs frequently show up when software is supplied with unexpected input, or when the software is run in an environment not initially anticipated by its developers.

Debugging is the act of hunting down and fixing bugs. Experienced developers acknowledge that bugs happen, and learn a set of skills to make fixing them easier. Tracking down a bug can be rewarding and fun: it can require rethinking the logic of a program, or coming up with creative ways to expose the bug. But when a bug you were sure you had fixed pops up again, the fun turns into frustration. And some things that users report as bugs dance precariously close to being feature requests. Agreeing with your clients about the difference between a bug and a feature request could be considered part of the task of debugging.

Often, when bugs are reported by users, the first challenge is reproducing the error condition. Reproducing the bug sounds simple, but it’s often where a lot of debugging time is spent. The remainder of debugging effort is spent on correcting the syntax or logic that caused the bug.

Rails helps you combat bugs by first making sure they never happen ...

Get Rails Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.