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.

PostgreSQL: How to show database size

pg_database_size returns a database’s size in bytes; pg_size_pretty formats it into readable units like GB.

The Easiest Way to Parse URLs with JavaScript

Parsing URLs is simpler with an <a> element than with new URL(...), and it also handles incomplete relative paths; IE11 may omit the leading slash.

Icon font vertical alignment in Windows

Icon fonts can line up differently across Windows, Linux and macOS, and vertical-align alone may not fix the baseline mismatch. Adjusting spacing with display:inline-block, padding and margins is often more reliable.

Hiding the clear input button of Edge (with EdgeHTML engine)

Edge and IE11 render a built-in clear button on text inputs that can conflict with custom UI; input::-ms-clear hides it.

Double loading issue with Ruby default gems

Bundler can activate a Ruby default gem before Gemfile.lock is evaluated, causing a version mismatch and Gem::LoadError when a newer installed release is required.

How to debug issues with zeitwerk and Rails

Zeitwerk autoloading problems in Rails can be hard to trace during boot; Rails.autoloaders.log! and bin/rails zeitwerk:check help reveal constant-to-file mapping issues.

Waiting for page loads and AJAX requests to finish with Capybara

Capybara browser tests can fail while page loads or AJAX requests are still pending; waiting for visible results reduces flickering and unreliable assertions.

Project maintenance: four levels of code quality

Code quality determines maintainability, from merely working code to reliable, readable, and changeable code. Long-lived projects need at least readable code; short-lived code can stop at reliable code.

Rails: Remove Blank Values from Collections

Rails collections often retain empty strings, nil, whitespace, empty arrays, hashes, and false values; compact_blank removes them from arrays and hashes in Rails 6.1+.

Ruby constant lookup: The good, the bad and the ugly

Ruby constant resolution can pick the wrong class through namespace fallbacks, causing autoloading bugs and unexpected references in Rails, especially with nested models.

CSS Support Guide for Email Clients

CSS support in e-mail clients is inconsistent, so HTML email styling often breaks across providers. A compatibility overview helps identify unsafe features before sending.

Postgresql: Paginate and count in one query using window functions

High-latency pagination queries can be reduced to one PostgreSQL statement by using COUNT(*) OVER() to return page rows and total rows together.

JavaScript: Testing whether the browser is online or offline

Browser connectivity can be misleading: navigator.onLine often stays true without usable internet. A real fetch with timeout can confirm whether requests actually work.

How to solve Selenium focus issues

Browser focus loss makes Selenium tests flicker red and green, especially with Firefox and parallel runs. Explicit focus and blur handling and focus-independent tests improve stability.

Squashing several Git commits into a single commit

Combining WIP changes into one clean commit reduces noisy history and simplifies merging feature branches, but rebasing can rewrite or lose commits if done carelessly.

You are not using filter_map often enough

Ruby 2.7 adds filter_map for combining selection and transformation in one pass, avoiding map/compact or select/map chains on any Enumerable.

Josh McArthur: Fancy Postgres indexes with ActiveRecord

Case-insensitive address uniqueness in Rails needs a functional PostgreSQL index and custom model validation when built-in helpers do not support expression-based constraints.

ruby-sass: Do not use comments between selector definitions

Comments between grouped selectors can make ruby-sass drop part of a rule, breaking hover fallback styling. sassc, Node Sass, and Dart Sass are not affected.

Rails: How to find records with empty associations

Find Rails records with no associated rows, such as decks without cards or cards without a deck, using where.missing or left_joins.

Do not forget mailer previews

Mailer previews often break when mailer code changes, and automated checks can catch missing updates before they reach development workflows.

Rails: Default HTTP status codes when redirecting

Redirects in Rails use different default status codes in controllers and routes, and an unintended permanent redirect can affect browser behavior.

Show a JS fiddle in fullscreen

Open a JS Fiddle in fullscreen by appending /show to the URL; the viewer loads the fiddle without the editor chrome.

IRB's multi-line autocomplete and how to disable it

IRB’s multi-line completion can slow down input and make Backspace unreliable; --nomultiline or IRB.conf[:USE_MULTILINE] = false disables it while keeping Tab completion.