FirstDEV blog
  • Home
  • Ruby
  • Ruby On Rails
  • Tips
  • Solutions
  • About
Subscribe

Ruby

We cover Ruby! 2.x / 3.x +

Ruby 3

Safe Navigation, dig, and fetch — Choosing the Right Nil Guard

user&.profile&.address&.city looks defensive and reads as careful code. It’s also a sentence that says “I don’t know which of these can be nil, so I’ve assumed all of them can” — and when

Rajan Bhattarai Rajan Bhattarai 11 min read
Ruby 3

StringScanner — Parsing Text Without the Regex Overhead

There’s a stage in every text-parsing problem where the regex stops being the right tool. You’ve got a pattern with four alternations and three lookaheads, it’s slow, it’s unreadable, and it still can’t

Rajan Bhattarai Rajan Bhattarai 11 min read
Ruby 3

Decorators in Ruby — Delegation Patterns That Don't Fall Apart

You want to add display logic to a model without putting it on the model. So you reach for SimpleDelegator, wrap the object, add three methods, and it works — until something calls

Rajan Bhattarai Rajan Bhattarai 10 min read
Ruby 3

ObjectSpace and Memory Profiling — Finding Leaks Before Production Does

A Puma worker starts at 180MB and sits at 1.4GB by the end of the day. Restarting fixes it, so someone adds a memory-based worker killer and the problem becomes invisible rather than

Rajan Bhattarai Rajan Bhattarai 11 min read
Ruby 3

Writing Fast Ruby — Benchmarking with benchmark-ips and Reading the Results Honestly

Someone on the team claims map.compact is faster than filter_map. Someone else says the opposite. Both have benchmarks. Both benchmarks are wrong, in different ways — one measured a hundred iterations on a

Rajan Bhattarai Rajan Bhattarai 11 min read
Ruby 3

TracePoint in Practice — Instrument Your Code Without Reaching for a Gem

Something in a Rails boot sequence is defining a method you can’t find. A query is being issued from a code path you can’t identify. An exception is swallowed six layers down and

Rajan Bhattarai Rajan Bhattarai 10 min read
Ruby 3

Frozen String Literals in Production — Real Wins and the Gotchas Nobody Mentions

The # frozen_string_literal: true magic comment sits at the top of nearly every file in a modern Ruby codebase, added by RuboCop, accepted without much thought. It’s a genuine optimization — measurably fewer

Rajan Bhattarai Rajan Bhattarai 11 min read
Ruby 3

Ruby's Object Model — Eigenclasses, Method Lookup, and What super Really Does

You can write Ruby for years without knowing what an eigenclass is. Then one day a gem defines a method you can’t find with grep, super calls something you didn’t expect, and define_method

Rajan Bhattarai Rajan Bhattarai 11 min read
Ruby 3

Memoization at Depth — Where ||= Works, Where It Quietly Breaks

@value ||= expensive_call is the first optimization most Ruby developers learn and the one they keep using long after it stops being correct. It works beautifully for a non-nil, non-false result computed from

Rajan Bhattarai Rajan Bhattarai 11 min read
Ruby 3

Writing Cleaner Ruby — The Terser Syntax Patterns Worth Adopting

Ruby has quietly accumulated a set of shorthands over the 3.x series — numbered block parameters, hash value omission, rightward assignment, anonymous argument forwarding. Each removes a small amount of ceremony. Adopted carelessly

Rajan Bhattarai Rajan Bhattarai 10 min read
Ruby 3

Hash Methods Worth Knowing — transform_keys, transform_values, filter, and merge with a Block

Hashes are the workhorse data structure of most Ruby applications — API responses, configuration objects, parameters, aggregations. Ruby’s Hash class has been steadily gaining methods that reduce the boilerplate of common transformations. transform_keys,

Rajan Bhattarai Rajan Bhattarai 10 min read
Ruby 3

filter_map and Modern Enumerable — Ruby's Most Useful Recent Additions

Ruby’s Enumerable module has been quietly gaining methods that make common collection operations more expressive without adding complexity. filter_map alone replaces a pattern that every Ruby developer has written dozens of times. Combined

Rajan Bhattarai Rajan Bhattarai 11 min read
Ruby 3

Ruby String Methods You're Probably Underusing — format, scan, match, and gsub with Blocks

String manipulation is one of those areas where developers develop habits early and rarely revisit them. split, include?, gsub, strip — these cover a lot of ground. But Ruby’s String class has methods

Rajan Bhattarai Rajan Bhattarai 10 min read
Ruby 3

Method Objects in Ruby — Treating Methods as First-Class Values

Ruby methods are first-class citizens in a way that most developers don’t fully use. You can grab a method as an object, pass it around, convert it to a proc, unbind it from

Rajan Bhattarai Rajan Bhattarai 9 min read
Ruby 3

Ruby Threads and Thread Safety — Practical Concurrency Without the Chaos

Threads in Ruby have a complicated reputation — partly because of the Global Interpreter Lock (GIL) in MRI Ruby, partly because concurrent code genuinely is harder to reason about, and partly because most

Rajan Bhattarai Rajan Bhattarai 10 min read
Page 1 of 3 Older Posts »
FirstDEV blog © 2026
Proudly published with Jekyll & using Jasper2
Latest Posts Twitter
FirstDEV blog

Check viewARU - Brand Newsletter!

Newsletter to DEVs by DEVs - boost your Personal Brand & career! 🚀