Rails: Using database default values for boolean attributes

Boolean fields in Rails are safer with database defaults and NOT NULL constraints; application-level fallbacks are brittle, especially for tri-state values and instance-dependent defaults.

Configuring RubyGems to not install documentation by default

Gem installations waste time generating local docs that are rarely used; disabling documentation by default speeds up manual installs with gem and ~/.gemrc.

How to turn images into inline attachments in emails

External images in emails can fail in some clients; inline attachments with Rails and attachments.inline keep images visible, but turn messages into multipart emails and use content IDs.

Rails: Encrypting your database information using Active Record Encryption

Rails 7 app data can be stored as encrypted attributes with deterministic lookup support, but search, grouping, and bulk updates become limited.

git: find the version of a gem that releases a certain commit

Find the gem version that first contains a commit by using git name-rev --tags; it points to the next release tag after the change.

Rails: Accessing helper methods from a controller

Controllers can call view helpers in Rails 5+ through helpers, while older Rails versions use view_context to reach methods like link_to.

ActiveRecord: Specifying conditions on an associated table

ActiveRecord queries can filter on columns from an associated table without raw SQL, using subqueries, ID plucking, traverse_association, or joins.

Pattern: Disabling a certain feature in tests

Integration tests often break on cookie banners or captchas. A test-only switch disables them by default while allowing targeted reactivation for specific cases.

Lazy-loading images

Loading large page images only when they enter the viewport cuts bandwidth use and can improve perceived speed. Missing crawler support and layout shifts remain common issues.

Preconnect, Prefetch, Prerender ...

Early browser hints can reduce page load latency by preparing DNS lookups and connections before navigation.

RSpec: How to compare ISO 8601 time strings with milliseconds

Rails JSON serializes times with milliseconds, so iso8601 and to_json can differ in RSpec expectations. Using to_json keeps time string comparisons matching.

How to kill a Rails development server by force

A stuck Rails development server can keep port 3000 busy and trigger EADDRINUSE; lsof and kill -9 can force it down.

Consul 1.3.0 lets you override generated controller methods

Consul 1.3.0 allows overriding generated controller methods mapped with :as, while super preserves the original implementation for added scope conditions.

Fixing wall of net/protocol warnings

Rails boot warnings from duplicate net-protocol constants after upgrading can be silenced by avoiding automatic loading of net-http, net-imap, net-protocol, and net-smtp.

Why Sidekiq Jobs should never be enqueued in an `after_create` or `after_save` callback

Database transactions can roll back after after_save, leaving Sidekiq jobs queued for records that never persist. after_commit runs after persistence and avoids this race.

Heads up: expect(object).to receive(:method_name) does not execute the original implementation of the method

receive(:method_name) stubs the original method implementation, so callbacks or side effects do not run during expectations. and_call_original preserves the real behavior.

How to make your git aliases work with both master and main

Git aliases can break when default branches differ between repositories. Using init.defaultBranch lets shared aliases adapt to master or main.

Spreewald: patiently blocks must not change variables from the surrounding scope

patently blocks must keep local variables inside the block; rebinding an outer variable breaks retries because later attempts reuse the changed value.

Signed URLs with Ruby on Rails

Temporary, tamper-resistant links can be built in Rails without extra database columns or conditional logic by using ActiveRecord's signed_id and .find_signed.

Finding a method name on a Ruby object

Search an object's method list when you only know part of a name; grep and method-set subtraction help isolate relevant public or private methods.

RubyMine's clipboard can hold more than one string

RubyMine keeps a clipboard history, letting you paste earlier copied strings instead of only the most recent one.

Ruby: Natural sort strings with Umlauts and other funny characters

Ruby string sorting misorders German umlauts, mixed case, and embedded numbers. to_sort_atoms, natural_sort, and natural_sort_by provide natural ordering.

Bundler 2.3 honors the version specified in `BUNDLED_WITH`

Bundler 2.3 respects the BUNDLED_WITH version in Gemfile.lock, preventing silent lockfile changes and installing the required version automatically.

Fixing Yarn 1 error "unexpected end of file"

Yarn 1 can fail with "unexpected end of file" during yarn install when registry downloads disconnect; increasing the network timeout or retrying can work around it.