Careful: `fresh_when last_modified: ...` without an object does not generate an E-Tag
Passing last_modified without an object skips ETag generation, so second-level timestamps can make distinct responses look identical and break cache-related tests.
Some nifty Rails Rake tasks
Useful Rails rake tasks expose code statistics, comment tags, and environment details for quick project inspection.
When sessions, cookies and Clearance tokens expire and how to change it
Rails session and cookie lifetime defaults can be surprising, and Clearance authentication tokens expire separately. Changing expiry settings requires different configuration points or a patch to sign_in.
Using feature flags to stabilize flaky E2E tests
Always-on UI behaviors like polling, animations, autocomplete, and lazy loading can make E2E tests flaky; feature flags disable them by default and re-enable them only where needed.
How to access your Rails session ID
Accessing the Rails session ID is only possible when a session ID exists; exposing it is risky and should be done carefully.
Solving "cannot remove Object::ClassMethods"
rake can fail with a misleading cannot remove Object::ClassMethods error when a hidden boot-time exception triggers Rails cleanup instead of the real cause.
Geordi 1.0 released
Geordi 1.0 consolidates Rails project commands into a single CLI with command lookup, dependencies, and new setup, update, console, shell, and test workflows.
Unsafe string methods in Rails
Rails SafeBuffer loses HTML safety after many string transformations, and in-place replacement can raise TypeError; this prevents injection tricks through user input.
How to diff two strings in Ruby
Compute readable differences between two strings in Ruby or Rails with the differ gem, including word, line, and character comparisons plus HTML or color output.
Rails 5's ApplicationRecord is the place to put generic model logic
Rails 5 model classes inherit from ApplicationRecord, making it the shared home for logic used by all application models instead of patching ActiveRecord::Base.
How to set up SMTP email delivery with a Gmail account
Rails applications can send mail through Gmail’s SMTP server with smtp_settings; Google app passwords enable delivery when two-factor authentication is enabled.
Upgrade from Ruby 1.8.7 to Ruby 1.9.2 on Ubuntu
Upgrading Ubuntu from Ruby 1.8.7 to 1.9.2 can break Rails 2 apps using RSpec and removes installed gems, but Bundler can restore dependencies.
Asset Pipeline Basics
Rails asset delivery relies on manifests and explicit requires; precompilation output helps verify URLs and troubleshoot missing or misplaced assets.
Fixing "undefined local variable or method `version_requirements' for #<Rails::GemDependency:0x...> (NameError)"
Rails startup can fail with a NameError when version_requirements is missing on Rails::GemDependency; a small environment.rb patch restores compatibility with newer RubyGems.
Rails: How to get PostgreSQL version being used
Get the PostgreSQL server version from a Rails app or console using ActiveRecord::Base.connection.select_value('SELECT version()') when you need database details at runtime.
Speed up JSON generation with oj
Use oj to generate JSON much faster for large Ruby hashes, but account for symbol handling, Rails compatibility, and HTML escaping to avoid XSS.
How to fix: Gems are unavailable although they are installed
Rails or Rake can report missing gems even when they are installed; wrong Bundler configuration or release-directory leftovers often redirect gem lookup to the wrong place.
Dynamic conditions for belongs_to, has_many and has_one associations
Runtime association filters are hard in Rails because :conditions cannot take a lambda; a string-interpolation hack or proc can evaluate date-based rules.
How to mount a legacy database to migrate data
Legacy data can be imported into a new Rails app by connecting a second database and mapping old tables and columns with Active Record models.
Rails 2: Refuse response formats application-wide
Bot traffic can trigger ActionView::MissingTemplate by requesting bogus URL suffixes. Restricting allowed request formats application-wide prevents invalid format parameters from reaching controllers.
Disable Rails XSS protection in ActionMailer views
Rails XSS protection can escape ActionMailer email bodies unexpectedly. A configuration initializer prevents rails_xss from escaping mail content.
Nicer alternatives to def_delegator or def_delegators
def_delegator and def_delegators are hard to read; delegate or a small wrapper method makes Rails delegation clearer.
Rails: How to use custom flash types in controllers
Custom flash types let controllers use extra redirect messages such as success, useful for Bootstrap-style alerts beyond notice and alert.
Using Spring and parallel_tests in your Rails application
Spring keeps bin/rails and bin/rspec fast, while parallel_tests can break shared test runs unless Spring is disabled in parallel contexts.