Ruby: Using named groups in Regex

Named capture groups make complex regular expressions easier to read and extract values from, with match returning nil on no match and named_captures available in Ruby 2.4+.

When reading model columns during class definition, you must handle a missing/empty database

Class definition code that inspects model columns can crash startup when the database is missing or empty, blocking db:create and db:migrate.

ActionMailer: Previewing mails directly in your email client

Inspect Rails emails in a real mail app by exporting a Mail::Message to .eml and opening it, instead of relying only on browser previews.

Carrierwave processing facts

CarrierWave processing runs differently on originals and versions: class-level processing affects only the original file, while callbacks run for each file instance.

Heads up: pg_restore --clean keeps existing tables

pg_restore --clean removes data from dumped tables but leaves extra tables in place, which can break later migrations when restoring a staging dump locally.

Auto-generating plain-text bodies for HTML e-mails in Rails apps

HTML e-mails in Rails need a plain-text part to avoid spam penalties; premailer-rails can generate it automatically and be tuned for line length and formatting.

Regular tasks for long-running projects

Long-running projects need regular upkeep to avoid stale dependencies, growing data, and bloated storage that raise costs and slow applications.

Rails: Prefer parsing dates with Date.strptime()

Date.parse guesses date formats and can accept invalid input, producing unexpected dates. Date.strptime validates against an explicit pattern and avoids ambiguous parsing.

How to examine an unknown Ruby object

Inspect unfamiliar Ruby objects during debugging by listing methods, filtering names, and checking instance variables when source code is unavailable.

A quick introduction to CORS

Cross-origin browser requests need explicit server approval; otherwise the Same-Origin Policy blocks access. CORS uses Origin and Access-Control-Allow-Origin headers, with preflight checks for some methods.

Raising JavaScript errors in Ruby E2E tests (RSpec, Cucumber)

Selenium E2E tests can miss frontend JavaScript errors because browser console logs do not fail specs by default. BrowserConsole raises on console errors and supports ignore rules.

Geordi: How to rerun failed features

Rerun failing Cucumber scenarios automatically or from tmp/parallel_cucumber_failures.log when a test run leaves broken features behind.

Ruby: How to use prepend for cleaner monkey patches

prepend makes Ruby monkey patches cleaner by inserting an extension before the original implementation, so super still reaches it and ancestor chains stay readable.

HTML forms with multiple submit buttons

Forms can offer multiple submit actions such as save, accept, or reject, but the server must know which button was pressed. formaction sends each button to a different URL.

Best practices: Large data migrations from legacy systems

Large legacy data migrations need deep source-system understanding, fast failure, dedicated logging, and traceable migration metadata to keep long-running imports debuggable and verifiable.

Project management best practices: The story tracker

The tracker acts as the source of truth for project work, separating developer and non-developer stories and keeping developer items fully specified before backlog intake.

Project management best practices: Project team responsibilities

Clear role separation in larger projects reduces coordination gaps, delays, and ownership confusion. The project lead drives delivery and technical decisions; the PM handles customer-facing requirements and acceptance.

How to make changes to a Ruby gem (as a Rails developer)

Ruby gems need manual file loading, multi-version support, and their own release workflow, unlike Rails apps. Safe changes depend on understanding structure, tests, versioning, and packaging.

Optimizing images for the web

Fast webpages need smaller image files without visible quality loss; resizing, stripping metadata, and using formats like WebP can greatly reduce size.

Devise: Invalidating all sessions for a user

Stolen Rails session cookies can remain usable after logout with Devise. Invalidating them requires changing the authentication salt, resetting the password, or storing sessions server-side.

Whenever: Don't forget leading zeros for hours!

Whenever can misread 24-hour times without a leading zero, turning 3:00 into 3pm instead of 3am. chronic_options can switch parsing to a 24-hour clock.

When you want to format only line breaks, you probably do not want `simple_format`

Rendering text with only line-break handling can avoid simple_format's HTML-preserving side effects. A small helper or white-space: pre-wrap keeps output predictable.

Don't sum up columns with + in a SQL query if NULL-values can be present.

+ arithmetic in SQL turns the whole result NULL when any operand is NULL; SUM and COALESCE(..., 0) avoid silent loss of totals.

Writing strings as Carrierwave uploads

CarrierWave needs a filename for string or stream uploads through ActiveRecord; a small StringIO wrapper with original_filename avoids TypeError and works with Zeitwerk.