Systems | Development | Analytics | API | Testing

Custom Exceptions in Ruby: Classes, Messages & Hierarchies

To create a custom exception in Ruby, define a class that inherits from StandardError: class PaymentError < StandardError; end. Raise it with raise PaymentError, "card declined" and rescue it by class. Inherit from StandardError, not Exception, so a bare rescue still catches it. Pass a default message by overriding initialize and calling super. Ruby’s built-in exception classes describe the language’s failure modes, not your application’s.

Handling Exceptions in Grape for Ruby: rescue_from and error!

Grape handles exceptions with rescue_from blocks declared on your API class: rescue_from :all catches every exception, while rescue_from ActiveRecord::RecordNotFound targets one class. Inside an endpoint, error!("Not Found", 404) halts with a formatted error, defaulting to status 500. Without a handler, invalid params return 400 and other exceptions bubble up to Rack. This guide covers Grape 3.3. Every response body, status code, and error message was verified on Grape 3.3.5, Rack 3.2.7, and Ruby 3.4.10.

Ruby vs. Python (Why Python Won and Ruby Didn't)

In 2006, the TIOBE Index crowned Ruby its Language of the Year for posting the fastest growth rate of anything on the list. Two decades later, it's settled in around - respectable, but a long way down from where it once stood. Ruby went from "the future of programming" to "wait, people still use that?" within a single career. This isn't a eulogy, though - stick around, because Ruby is very much alive, just not where the headlines are looking.

Test-Commit-Revert: A useful workflow for testing legacy code in Ruby

It happens to all of us. As software projects grow, parts of the production code we ship end up without a comprehensive test suite. When you take another look at the same area of code after a few months, it may be difficult to understand; even worse, there might be a bug, and we don't know where to begin fixing it. Modifying production code without tests is a major challenge.

Everything you need to know about Ruby 4.0

Ruby 4.0 is a major release, launched on Ruby’s 30th anniversary (December 25, 2025) to celebrate three decades of the community, not due to major breaking changes. I was surprised to learn that Ruby doesn’t actually follow semantic versioning! Instead, Matz (Ruby’s creator) increases the major version when changes impress him. This version marks 30 years of Ruby and introduces features to extend the language.

An Introduction to Ruby Parsing with Prism

You might have heard about Prism, the new Ruby parser. Perhaps you've heard it's faster, more reliable, and more powerful than what we had before. Or maybe you never took a compilers class and aren't sure about what this actually means. I'm here to tell you all about it, and how it's changing our lives as Ruby developers. Today, I want to take you from square one to writing your first transpiler.

Completing, Integrating, and Publishing Our Game with DragonRuby

In part one of this series, we started developing a simple Flappy Bird clone game using the DragonRuby game development toolkit. We didn't come very far, though — we stopped after integrating player input to keep our plane afloat. In this second and concluding part, we'll implement the remaining simple game mechanics. We'll also take a brief look at interfacing with an HTTP server and publishing our game on itch.io.

An Introduction to Game Development with DragonRuby

The DragonRuby Game Toolkit is a powerful, cross-platform 2D game engine that allows you to create fun game titles while staying in your favorite developer-friendly language. What's not to love? In this post, we are going to cover the basics of game development with DragonRuby. We will use a "Flappy Bird" clone to explain the fundamental concepts. But before we get started, let's address two initial concerns you might have about DragonRuby right off the bat.

How to Read Code from the Showcase Ruby on Rails Engine

Reading a lot of code from very senior engineers is probably one of the best ways to level up as a Ruby on Rails developer. By doing so, we can learn new tips and techniques that we can reuse in our jobs. Thanks to open source, we can read code written by the best developers from all over the world, and for free! However, reading code from a Ruby gem or a Rails engine for the first time without being guided can be daunting. There are so many files; how do we even know where to start?