Rails eager_load, joins and includes - when to use what

Rails eager_load, joins and includes - when to use what

Rails eager_load, includes, preload, and joins each fight slow queries differently: LEFT OUTER JOIN versus separate queries, how includes picks its strategy, and when a plain joins is enough. Clear examples showing which loading method to choose for each situation.

Ruby in browser via WebAssembly

Ruby in browser via WebAssembly

Ruby 3.2 runs in the browser through WebAssembly: embed Ruby in a script tag with ruby-wasm-wasi or drive the Ruby VM from JavaScript and mix it with HTML. Working examples plus honest limits: no threading or networking, and no extra gems without a custom wasm image.

Solutions for const and enums per class in Ruby

Solutions for const and enums per class in Ruby

Three ways to define constants and enums per class in Ruby: the ActiveRecord enum macro, a mixed style combining frozen constants with enum, and a dependency-free PORO version. Code for each solution and a comparison to help you pick the right one.

Factory Pattern with auto-detecting classes in Ruby

Factory Pattern with auto-detecting classes in Ruby

The Factory Pattern in Ruby, then a step further: using naming conventions and regular expressions so the factory auto-detects which notification class to instantiate. Complete code for both versions, plus when strict class listing is the safer choice.

Anonymous Arguments Passing Improvements in Ruby 3.2

Anonymous Arguments Passing Improvements in Ruby 3.2

Ruby 3.2 adds new syntax for anonymous arguments: forward positional and keyword arguments with bare * and ** and unpack them inside the method, no more digging through kwargs hashes. A before-and-after example shows how much cleaner argument passing gets.

Why callbacks are bad in Rails models

Why callbacks are bad in Rails models

ActiveRecord callbacks bring tight coupling, slower transactions, and painful debugging. Why before_save and after_save hooks in Rails models cause trouble, and how replacing them with an explicit process class makes the same flow readable and easy to debug.

Consider using Apipie gem twice

Consider using Apipie gem twice

Apipie looks like an easy way to document a Rails API, but check its limits first: no advanced type constraints like exactly_one_of, only partial OpenAPI support, and weak handling of output examples. What to weigh before picking the gem for a larger application.