Don't forget: Automatically remove join records on has_many :through associations
has_many :through associations can leave orphaned join rows after deleting a parent record. dependent: :destroy removes the join records while keeping the associated records.
Rails: Handling actions that need to happen after all transactions
ActiveRecord.after_all_transactions_commit runs work only after every open transaction commits, or immediately when none is open. It suits side effects like email delivery after persisted state changes.
Rails: Testing exceptions with the rescue_responses setting
Rails 7.2 changes show_exceptions defaults in tests, so rescued RecordNotFound often becomes a 404 response instead of a raised exception.
RSpec: Defining negated matchers
RSpec::Matchers.define_negated_matcher creates readable inverse matchers for composed expectations and clearer failure messages, but only for atomic matchers with unambiguous negation.
A modern approach to SVG icons
SVG icons can be sized and colored like text without image tags, icon fonts, or extra server work by using CSS masking.
Regex: Be careful when trying to match the start and/or end of a text
Regular expressions can accept embedded newlines when ^ and $ are used; \A and \z anchor the whole string and avoid unsafe validation matches.
Statistics and Reports on Web Performance Optimization
Web performance optimization affects user experience and business metrics, with case studies and experiments showing measurable gains from faster sites.
How to use Parallel to speed up building the same html partial multiple times (for different data)
Parallel rendering can speed up repeated partials for long lists, but database connections must be cleaned up and transaction-based test setup may break.
Choosing the right gems for your project
External libraries add maintenance and security risk, so picking a Ruby gem needs attention to necessity, test quality, license, maturity, and scope fit.
How to iterate over an Enumerable, returning the first truthy result of a block ("map-find")
Need the first derived value from a collection without mapping everything twice; Ruby can do it in one pass with break or lazy filter_map.
Heads up: Capybara 3's text matchers no longer squish whitespace by default
Capybara 3 no longer squishes whitespace when matching text across elements, so tests that relied on rendered text comparison can fail unless normalization is enabled.
RubyMine: Efficiently filtering results in the "Finder" overlay
RubyMine Finder searches can return huge result sets; file masks, directory limits, regex, and other filters narrow matches and speed up locating the right code.
Testing for Performance: How to Ensure Your Web Vitals Stay Green
Frontend changes often erode loading speed and visual stability. Web Vitals tests can lock in LCP and CLS scores by checking them in the browser under throttled network conditions.
How to auto-resize a textarea (or other inputs) in pure CSS
field-sizing: content lets textareas and other inputs grow to fit their contents, but Firefox and Safari still need a JavaScript fallback.
You don't always need a custom matcher to write clean RSpec tests
Repeated RSpec assertions can be extracted into custom matchers, but some cases are better served by private helper methods when reuse would be too awkward.
Different ways to set attributes in ActiveRecord
ActiveRecord attribute assignment methods differ in persistence, validations, callbacks, timestamp updates, and readonly handling across Rails versions.
Error handling in DOM event listeners
DOM event handler exceptions are swallowed, so later listeners and dispatchEvent() continue running. Uncaught errors still reach the browser log and window error event.
Don't sum up columns with + in a SQL query if NULL-values can be present.
+ arithmetic in SQL turns the whole result NULL when any operand is NULL; SUM and COALESCE(..., 0) avoid silent loss of totals.
Inspecting the page content in a Cucumber session
Inspect page text in a Cucumber session by pretty-printing the HTML content instead of digging through full markup; useful for debugging and custom steps.
Rails: How to write custom email interceptors
Global mail interception in Rails can prefix subjects by environment and redirect staging mail to a fallback address unless recipients are allowlisted.
Differences between transactions and locking
Concurrent database access needs two different tools: transactions for atomic multi-row changes and locks for exclusive access; using the wrong one causes lost updates and deadlocks.
Rails: Report CSP Violations to Sentry
CSP violations can be sent to Sentry for monitoring, but browser extensions and high-traffic sites may generate noisy reports and filtering remains limited.
Simple gem for CLI UIs
Small dependency-free library for interactive terminal input and progress bars in CLI apps, with filtering prompts and basic formatted output.
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.