PostgreSQL: Difference between text and varchar columns

PostgreSQL character columns differ mainly in declared limits, not speed; unbounded varchar and text behave alike in Rails 4+, though some tools still render them differently.

Taking screenshots in Capybara

Capybara test failures can save screenshots and HTML automatically, with manual capture also available through save_and_open_page, save_screenshot, or Rails ScreenshotHelper.

redirect_to and redirect

Rails URL redirection can use redirect_to or routing redirect, with different status codes, query forwarding, and security implications.

Rails: Overriding view templates under certain conditions only

Use request-specific view paths to swap in alternate templates for selected conditions, with fallback to the default templates when no override exists.

Documenting your project's Node.js version in .nvmrc

Node.js compatibility depends on the exact runtime version, and projects can pin a supported release in .nvmrc so teams use the same setup.

Rails: Reporting CSP Violations to a log file

Capture CSP violation reports in a log file to spot blocked resources and browser-extension noise, with a dedicated Rails endpoint for incoming reports.

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.

How to set up database_cleaner for Rails with Cucumber and RSpec

Reliable test isolation for Rails with Cucumber and RSpec requires cleaning the test database up front and switching strategies for JavaScript-driven examples.

Rails: Talking to the database without instantiating ActiveRecord objects

Direct SQL access can avoid the overhead of instantiating ActiveRecord objects, but skips validations, callbacks, and custom accessors.

How to use Simplecov to find untested code in a Rails project with RSpec and Cucumber

Code coverage reveals untested Rails paths and blind spots across RSpec, Cucumber, and parallel test runs. SimpleCov can separate reports and add branch coverage.

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.

Rails: Composing an ETag from multiple records

fresh_when can combine multiple records into one ETag so associated data keeps cached pages invalidated when any rendered record changes.

Rails 7.1: Take care of the new production log default to standard out

Rails 7.1 changes production logging to standard out, which can break file-based logs in opscomplete setups unless the previous logger configuration is restored.

Zeitwerk: How to collapse folders in Rails

Rails can keep subfolders for organization without turning them into namespaces; collapse lets nested files define top-level constants instead of modules.

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.

Customizing Rails error messages for models and attributes

Rails error messages can be overridden at application, model, or attribute scope through locale YAML files, enabling clearer validation feedback than the default generic texts.

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.

Understanding race conditions with duplicate unique keys in Rails

validates_uniqueness_of can still allow duplicate records under concurrent requests; a unique database constraint prevents the race and turns collisions into ActiveRecord::RecordNotUnique.

Rails: Reverse Lookup a Fixture Name by it's id and table name

Find a Rails fixture name from a table and numeric id when the record label is unknown. ActiveRecord::FixtureSet can search loaded fixtures and return the matching key.

Three quick Rails console tips

Rails console access to routing helpers, request simulation, and view helpers speeds up debugging and quick checks without leaving rails console.

Using rack-mini-profiler (with Unpoly)

Rails performance debugging often hides slow SQL, view rendering, and N+1 queries; rack-mini-profiler helps surface bottlenecks during development.

Rails asset pipeline: Using ESNext without a transpiler

Modern browsers run most ES6 features natively, but Rails asset pipelines can still fail when Uglifier cannot minify newer syntax.

Rails: Destroying vs Deleting

Rails record removal differs in object instantiation, callbacks, and relation cache state; destroy honors dependent associations, while delete and delete_all skip them.

Rails I18n fallback locales

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