Sanitize user-generated filenames and only send files inside a given directory

User-supplied filenames can escape a target directory and expose arbitrary readable files. A guarded send_file helper keeps downloads inside the intended path.

Creating a self-signed certificate for local HTTPS development

Local HTTPS development often needs a trusted certificate for browser access. Self-signed or CA-signed certificates let localhost or wildcard hostnames run without warning dialogs.

Prefer using Dir.mktmpdir when dealing with temporary directories in Ruby

Unique scratch directories prevent flaky tests and stale files in parallel Ruby test runs. Dir.mktmpdir creates them safely and can use a custom base path.

Too many parallel test processes may amplify flaky tests

Flaky test suites can fail more often with too many parallel workers; limiting PARALLEL_TEST_PROCESSORS can reduce race-condition failures with only a small runtime cost.

How to discard a surrounding Bundler environment

Bundler variables leak into child processes and can force the wrong gemset when running nested bundle commands. Bundler.with_original_env restores the pre-Bundler environment; Bundler.with_unbundled_env is the modern Bundler-free variant.

How to not repeat yourself in Cucumber scenarios

Avoid duplicated Cucumber scenarios by sharing setup and assertions with step composition, helper modules, or scenario outlines. Better reuse keeps integration tests DRY and stack traces readable.

whenever: Make runner commands use bundle exec

whenever runner jobs can fail in cron because bundle exec is omitted, leading to Bundler load errors. A custom job_type restores the correct Rails runner command.

Geordi 10.0.0 released

Geordi 10.0.0 adds console and test-runner fixes, IRB configuration, and safer PostgreSQL dump restoration, with breaking changes to database drop handling.

Fix for mysql2 error "Incorrect MySQL client library version! This gem was compiled for x.x.x but the client library is y.y.y."

mysql2 runtime failures can stem from MariaDB/MySQL client library version mismatches on Linux, especially Ubuntu 22.04; LTS branches remove the client-version check.

Integrating or upgrading makandra-rubocop

Integrating makandra-rubocop into an existing Ruby codebase often means handling many current offenses, then fixing cops incrementally without blocking development.

Capistrano: exclude custom bundle groups for production deploy

Custom Bundler groups can still be downloaded during Capistrano deploys, slowing production and staging releases. Exclude unnecessary groups with bundle_without to avoid installing unused gems.

RSpec: Leverage the power of Capybara Finders and Matchers for view specs

View specs can stay fast and readable by querying rendered HTML with Capybara finders and matchers instead of relying on heavier request or feature specs.

Using Passenger Standalone for development

Local development can use Passenger Standalone as a zero-configuration Ruby app server with SSL and production-like behavior, replacing Webrick or Thin.

Case sensitivity in PostgreSQL

PostgreSQL compares strings case-sensitively, which can break email and username lookups and uniqueness checks. Lowercasing values or using case-insensitive matching avoids common bugs.

Ruby: Removing leading whitespace from HEREDOCs

Ruby 2.3+ supports <<~ for automatic HEREDOC unindentation; older versions can use ActiveSupport's String#strip_heredoc to remove common leading whitespace.

faviconit.com: Super-simple favicon generator

Simple favicon generation for web apps with image editing, multi-size output, and ready-made HTML for inclusion in Rails layouts.

Postgres: DISTINCT ON lets you select only one record per ordered attribute(s) for each group

PostgreSQL DISTINCT ON keeps one ordered row per group, useful for latest-per-user queries and other group-wise maximum results when plain DISTINCT is not enough.

Strong params: Raise in development if unpermitted params are found

Unpermitted request data can slip into Rails controllers unless action_on_unpermitted_parameters is set to log or raise; development can fail fast on unexpected keys.

How to send HTTP requests using cURL

Send HTTP requests from the command line with curl, including custom methods, form data, and basic authentication.

New gem: Rack::SteadyETag

Rack::SteadyETag makes HTML caching effective by keeping ETags stable when only CSRF tokens or CSP nonces change.

Haml Whitespace Preservation (or: Fixing Textarea Indentation in Haml)

Haml indentation can leak into preformatted text and textareas, adding unwanted leading spaces. Using ~ instead of = preserves whitespace without extra indentation.

A saner alternative to SimpleForm's :grouped_select input type

SimpleForm's :grouped_select can be awkward when you already have a flat collection and need grouped options. A group_by extension makes optgroup labels easier to derive.

How to migrate CoffeeScript files from Sprockets to Webpack(er)

Migrating CoffeeScript from Sprockets to Webpacker can keep existing classes and dependencies working by adding coffee-loader and adjusting imports and global namespace exposure.

ActiveRecord: Query Attributes

attribute? often checks presence like attribute.present?, but numeric values and associations behave differently; 0 can be false for ActiveRecord query attributes.