Creating predictable randomness in Ruby: The magic of seeds ruby

Creating predictable randomness in Ruby: The magic of seeds

Reproducible randomness in Ruby sounds like a contradiction, but seeds make it easy: how pseudo-random generators work, fixed seeds for tests, debugging, and procedural generation, creative ways to pick seeds, and the pitfalls that quietly break determinism.

Apr 28, 2025

Event Sourcing in practice: Lessons from the trenches

Event Sourcing in practice: Lessons from the trenches

Event Sourcing can be introduced to legacy systems incrementally, no big rewrite required. Lessons from production: the migration event technique, upcasting old events, right-sizing aggregates, stream lifecycles, and payoffs in audits, analytics, and debugging.

How to create multi trait inside trait in FactoryBot

How to create multi trait inside trait in FactoryBot

FactoryBot traits can nest other traits, letting you compose reusable test fixtures instead of copying attribute blocks. A quick refresher on traits, then the traitception pattern: defining traits inside traits and combining them for cleaner Rails test setup.

Embracing Hexagonal Architecture in Ruby

Embracing Hexagonal Architecture in Ruby

Hexagonal Architecture separates your business logic from databases, UIs, and external services using ports and adapters. What the pattern really means, a practical Ruby implementation, when it pays off, and the common problems teams hit when adopting it.

What is ENVIRONMENT in rake task?

What is ENVIRONMENT in rake task?

The :environment dependency in Rake tasks is what loads your Rails app, models, and database connections. What task my_task: :environment actually does behind the scenes, how the Rake dependency syntax works, and why skipping it breaks your custom tasks.

OJ is not as safe as you think for your JSON

OJ is not as safe as you think for your JSON

OJ speeds up JSON in Ruby, but Oj.mimic_JSON silently drops the script_safe option, opening the door to XSS, and adds time precision quirks. What its monkey patching really changes, the stability risks, and best practices for using OJ without surprises.

What is params.expect and how to use it in Rails 8?

What is params.expect and how to use it in Rails 8?

params.expect in Rails 8 replaces require/permit and fixes a real weakness: crafted params like ?user=string used to raise NoMethodError and 500 errors. How the new syntax works, how it handles arrays with precision, and how to migrate your controllers.

How to write custom RSpec matchers in your Ruby on Rails app

How to write custom RSpec matchers in your Ruby on Rails app

Custom RSpec matchers turn repetitive assertions into readable, reusable specs. Step by step: define a matcher with RSpec::Matchers.define, add clear failure messages, build flexible matchers that take arguments, and wire them into your Rails test suite.

What's new in Ruby 3.4

What's new in Ruby 3.4

Ruby 3.4 adds the new 'it' block parameter that makes .then chains and maps cleaner than numbered parameters, chilled strings as a step toward immutability, and enhanced Range operations. What each change looks like in practice, with before and after code.

How to add rate limiting in Ruby on Rails 8

How to add rate limiting in Ruby on Rails 8

Rate limiting in Rails 8 is built in: the rate_limit method declares limits per controller and action, like 3 requests per 2 seconds on create. How to combine short and long windows, protect unsafe actions, and practical suggestions for sensible limits.

Mastering database enums in Rails with Postgres - Guide

Mastering database enums in Rails with Postgres - Guide

Database enums in PostgreSQL give Rails apps type safety, implicit ordering, and faster queries than string columns. Single-value enums with validation, multi-select enum arrays, dynamic enum management, and the migrations that wire it all together.

How to run Rails console in safe sandbox mode?

How to run Rails console in safe sandbox mode?

Rails console sandbox mode wraps every database operation in a transaction and rolls it all back on exit, so you can experiment safely. How to launch it, plus the traps: database locking, non-rollbackable operations, and why production use still needs care.

How to get table size in PostgreSQL database?

How to get table size in PostgreSQL database?

PostgreSQL table size is more than the data: pg_table_size, pg_indexes_size, and pg_total_relation_size each measure different things. One ready SQL query lists every table with data, index, and total size, sorted by the biggest disk consumers first.

What is Frugal architecture?

What is Frugal architecture?

Frugal Architecture is Werner Vogels' framework for cost-conscious system design: three pillars (Design, Measure, Optimize) and seven laws, from treating cost as a non-functional requirement to continuous optimization, explained with practical examples.

The Truth About Password Security: Beyond Special Characters

The Truth About Password Security: Beyond Special Characters

Password security depends on entropy, not special characters. The math behind entropy = N * log2(R), why length beats complexity rules, why database breaches (not login guessing) are the real threat, and implementation tips for saner password policies.

How to listen to Rails events

How to listen to Rails events

ActiveSupport::Notifications lets you listen to Rails events like transaction.active_record without extra gems. How the instrumentation API works, subscribing to built-in Rails events, and publishing your own custom events for better observability.

Streamlining Rails controllers with custom filters

Streamlining Rails controllers with custom filters

Rails controllers bloated with subscription checks? Extract that logic into custom filter classes: a before_action that delegates to a dedicated object, giving cleaner controllers, clearer error messages, easier testing, and a pattern you can expand.