How to enable SSL in development with Passenger standalone
Local Rails development can serve both HTTP and HTTPS with Passenger standalone by enabling SSL and using a self-signed certificate.
When Date.today and Date.tomorrow return the same day...
Date.today and Date.tomorrow can return the same day when Rails has no configured time zone, causing date handling to drift between UTC and local time.
Don't use log level :debug in your production environments
log_level :debug can expose sensitive user data in Rails production logs, especially in SQL queries. Use :info, avoid SQL logging, and ensure filtered attributes are applied.
RSpec: how to prevent the Rails debug page if you want to actually test for 404s
Rails development and test environments often replace real 404s with the debug page, which can hide authorization failures in request specs.
Rails: How to check if a certain validation failed
Find out whether a Rails validation failed by checking ActiveModel::Errors types instead of messages, which is useful in tests and for validations with extra options.
Rails: Output helpers for migrations
Migration output can report progress while batch-updating records with announce and say_with_time in Rails 3.1+.
Organizing custom Date(Time) formats
Large Rails projects often duplicate date and datetime format strings, causing inconsistent output; named formats in Time::DATE_FORMATS and Date::DATE_FORMATS reduce repetition.
ActionMailer: Previewing mails directly in your email client
Inspect Rails emails in a real mail app by exporting a Mail::Message to .eml and opening it, instead of relying only on browser previews.
Rails: Accessing helper methods from a controller
Controllers can call view helpers in Rails 5+ through helpers, while older Rails versions use view_context to reach methods like link_to.
Cast an ActiveRecord to a subclass or superclass
becomes casts an ActiveRecord record to a different STI class so Rails can treat it as another type, while both instances share the same attributes.
Capistrano + Rails: Tagging production deploys
Production releases can be linked to Git history by tagging the deployed revision automatically with Capistrano.
Ruby and Rails: Debugging a Memory Leak
Growing memory usage in Ruby and Rails can exhaust a process and cause crashes; ObjectSpace.count_objects helps identify leaking object types, and derailed_benchmarks can aid diagnosis.
Upgrade guide for moving a Rails app from Webpack 3 to Webpack 4
Webpacker 4 and Babel 7 change config files, package names, asset paths, and polyfill imports when upgrading a Rails app from Webpack 3.
RSpec: How to turn off partial double verification temporarily
RSpec partial double verification blocks stubbing helper methods that come from Rails controllers; without_partial_double_verification or a spec config can disable it temporarily.
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.
Some tips for upgrading Bootstrap from 3 to 4
Migrating a larger Rails app from Bootstrap 3 to 4 often breaks styles, components and helper gems; planning library upgrades and rebuilding variables reduces the pain.
Accept nested attributes for a record that is not an association
Pass nested form data to a plain model reader such as home_page, without a real association. Works for singular references, with manual record construction and no deletion support.
Testing ActiveJob `limits_concurrency` with Solid Queue
ActiveJob concurrency checks can pass falsely with the :test adapter because blocked jobs still enqueue; using :solid_queue verifies real blocking behavior.
Mailcatcher: An alternative to inaction_mailer
Local email capture for Rails development avoids lost test messages and lets sent mail be viewed in a browser via MailCatcher.
Strict Loading Associations can prevent n+1 queries
Rails 6.1 strict loading prevents lazy association loading and raises errors when unread associations are accessed, helping avoid n+1 queries.
Rails: Default HTTP status codes when redirecting
Redirects in Rails use different default status codes in controllers and routes, and an unintended permanent redirect can affect browser behavior.
Disable PostgreSQL's Write-Ahead Log to speed up tests
Unlogged PostgreSQL tables can speed up Rails test suites by skipping the write-ahead log, but they raise crash-related data loss risk and stay unsuitable for production.
How to turn images into inline attachments in emails
External images in emails can fail in some clients; inline attachments with Rails and attachments.inline keep images visible, but turn messages into multipart emails and use content IDs.
MySQL: Disable query cache for database profiling
MySQL query caching hides true database timings during profiling; disabling it and Rails per-request caching reveals actual query costs.