How to organize large I18n dictionaries in Ruby on Rails

Rails can split large translation files across config/locales to keep model, view, and boilerplate strings manageable.

Guide to localizing a Rails application

Rails app localization affects text, URLs, formats, images, caching, and time zones; estimating effort means checking each layer for language-sensitive behavior.

How to use pessimistic row locks with ActiveRecord

Concurrent requests can overwrite each other or double-process a change. FOR UPDATE row locking in a transaction makes one request wait while the other completes.

Google Analytics: Changing the tracked URL path

Google Analytics can record a custom path instead of the current URL, useful for hidden tokens, grouped pages, or interactions without a request.

Why has_many :through associations can return the same record multiple times

has_many :through can return duplicate records when multiple join rows point to the same target; :uniq or DISTINCT removes repeated results.

Git: How to configure git to push only your current branch

Prevent accidental multi-branch pushes by setting push.default to current; it pushes only the checked-out branch, but new remote branches may need tracking setup.

Ruby: Making your regular expressions more readable with /x and alternative delimiters

Complex Ruby regular expressions become easier to read with %r alternative delimiters and the /x flag for whitespace and comments.

Ruby: Do not rescue without specifying exception classes

Bare rescue swallows StandardError and hides typos and other unexpected failures. Rescue only the specific exception you expect so monitoring still catches real bugs.

Gatekeeping: Guide for developer

Developer workflow for review-gated changes in Linear and GitLab, with branch, merge, reject, and staging steps to reduce client rejections.

ActiveRecord: When aggregating nested children, always exclude children marked for destruction

Nested form deletions can inflate aggregated totals when child records marked for removal are still counted. marked_for_destruction? filters them out before saving.

Don't compare datetimes with date ranges in MySQL and PostgreSQL

Date ranges can silently miss rows when compared to created_at datetimes in MySQL or PostgreSQL, because the end date is cast to midnight and late-day records are excluded.

Use Time.current / Date.current / DateTime.current on projects that have a time zone

Time zone-aware projects need Time.current, Date.current, and DateTime.current so values persist correctly; Time.now can write timestamps with the wrong zone.

How to use html_safe correctly

html_safe marks strings for unescaped insertion in Rails views, but does not unescape content; misusing it on user input can enable XSS.

Invoices: How to properly round and calculate totals

Invoice totals can miss cents when rounding is done too late or with floats; rounded item totals and BigDecimal keep net, VAT and gross consistent.

Detect the current Rails environment from JavaScript or CSS

Expose Rails.env on <html> to branch JavaScript and CSS by environment, making Selenium- and test-specific behavior easy to toggle.

Rails I18n fallback locales

Reuse one locale as a fallback for another instead of duplicating translations for regional variants like Austrian German.

Configuring ActionMailer host and protocol for URL generation

ActionMailer URL generation fails without a configured host and protocol. Rails can use hardcoded defaults or derive them from the request for mailers sent outside the request cycle.

Popular mistakes when using nested forms

Common Rails nested form pitfalls include missing accepts_nested_attributes_for, wrong form helper scope, and lost parameters that prevent child records from saving.

Merging two arbitrary ActiveRecord scopes

Rails ActiveRecord::Relation#merge can silently drop conditions on the same column; a subquery keeps combined scopes unambiguous.

Don't define a controller action called #process

Controller actions can accidentally overwrite internal ActionController::Base methods such as process, causing bizarre behavior and ArgumentError failures when middleware calls them.

Git: Advisory for cherry-picks to production branches

Cherry-picking individual commits to a production branch can create later merge pain because Git treats the same change as different history. Merge production back into main after each cherry-pick.

Use find_in_batches or find_each to deal with many records efficiently

Processing large record sets can exhaust memory when loading everything at once. find_in_batches and find_each keep memory usage lower for long-running data updates.

How DECIMAL columns deal with numbers exceeding their precision or scale

DECIMAL overflow and rounding differ by database: some systems reject out-of-range values, while others clamp or round to the nearest representable number.

Canceling event propagation

Event propagation can be stopped in different ways, with distinct effects on default actions, bubbling, and handlers on the same element. jQuery’s return false combines prevention and propagation stop.