Rails: Configuring the default sorting behaviour
Default ordering in ActiveRecord queries falls back to id unless implicit_order_column is set, which can make first and other finder calls return a different record order.
Efficiently add an event listener to many elements
Attaching one listener to many elements can slow the browser; delegating to document reduces setup cost and suits low-frequency events like click.
How to grep through the DOM using the Capybara API
Capybara can search page HTML in Ruby when CSS or XPath is awkward, but DOM changes can cause stale element errors.
Capybara: Accessing the parent of an element
Capybara can move from a selected node to its parent with find(:xpath, '..'), useful for checking surrounding links or containers in tests.
How to set Chrome's time zone in Selenium tests
Chrome time-dependent behavior in Selenium tests can require a different browser timezone than the host system. Emulation.setTimezoneOverride changes it for the whole session and must be reset afterward.
Rails: Keeping structure.sql stable between developers
db/structure.sql can vary between developers because database or CLI tool versions differ, creating noisy diffs and merge conflicts in Rails projects.
Implementing upload progress and remove button with ActiveStorage DirectUpload
In-place file uploads with ActiveStorage DirectUpload can show progress and support removing a chosen file before form submission.
A "text-wrap: balance" fallback approach
Fallback rendering for text-wrap: balance when browser support is missing, using explicit line breaks for older Safari and hiding them when balancing is available.
Implementing authentication and authorization for ActiveStorage blobs/files
Rails ActiveStorage direct uploads are public by default, so unauthenticated users can flood storage and access sensitive blobs without ownership checks.
Rails: Preloading associations in loaded records
Preloading nested associations on already loaded ActiveRecord objects avoids extra queries when rendering deeply related data and fits legacy Rails models via preload_associations.
HTML5: disabled vs. readonly form fields
Noneditable HTML form controls behave differently with disabled and readonly: submission, focus, and tab order change, and browser quirks can affect fieldset descendants.
How to create a terminal progress indicators in Ruby
Long-running Ruby scripts need terminal feedback, and a simple percentage display can track batch progress without extra dependencies.
How to automatically optimize SVG files with esbuild
SVG files often carry metadata and hidden elements that bloat output. svgo can run as an esbuild plugin to optimize them during builds.
Rails: Using PostgreSQL full-text search without a gem
PostgreSQL can handle full-text search in Rails without extra gems, with cached vectors, ranking, weighting, and stemming for faster, more flexible message search.
Overview of method delegation in Rails
Forwarding methods in Rails reduces deep call chains and boilerplate when exposing data from associated objects or decorators.
RSpec: Executing specs by example id (or "nesting index")
Running one RSpec example without line numbers avoids fragile file-position matches when specs change. Example ids, also called nesting indexes, target the example tree directly.
Rails: Overwriting default accessors
Customizing Active Record attribute readers and writers can trim or normalize values before persistence, while direct attribute storage bypasses other overridden behavior.
How to not die with ActionView::MissingTemplate when clients request weird formats
HTTP clients can request unsupported formats and trigger ActionView::MissingTemplate when only HTML templates exist; restricting routes or responding with 406 avoids the error.
Flexbox: flex-basis vs. width vs. min-width vs. max-width
CSS Flexbox sizing can be confusing when flex-basis, width, min-width, max-width, and content size compete. min-width: 0 often prevents overflowing children.
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.
Rails routing: Using constraints to avoid "Missing template" errors
Route constraints prevent ActionView::MissingTemplate errors on wrong requests by returning 404s instead of reaching an unmatched format or template lookup.
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.
Why your Cucumber feature loses cookies when run under Selenium
Cucumber/Selenium tests can lose cookies and sessions when the app and browser run in different times, because old dates make cookies expire immediately.
Clean code: Avoiding short versions in command options
Shared command examples are easier to read and search when options are written out instead of shortened to cryptic flags.