Rails: Accessing strong parameters
Rails parameters need careful filtering before mass assignment or URL generation; expect, require, permit, slice, and except help avoid security issues and noisy extras.
Rails: Looking up constants by their name string
Rails constantize and safe_constantize turn strings into constants, but untrusted input can resolve dangerous classes; validate with an allowlist first.
How to speed up JSON rendering with Rails
Slow Rails JSON endpoints often waste time in JBuilder, loading full records, and Ruby object allocation. pluck, database aggregation, and cached materialized views can cut response time dramatically.
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.
How to: Rails cache for individual rspec tests
Rails caching can be enabled for a single RSpec example without changing global test settings. File and memory stores let cache behavior be verified in isolated tests, including parallel runs.
ActiveRecord: count vs size vs length on associations
size is usually the right way to count associated records in Rails; count can ignore loaded children, while length loads everything.
Automatic Log Rotation in Rails
Rails log files rotate automatically around 100 MB, and config.log_file_size lets you cap growth and keep logs manageable in development, test, or production.
Escape a string for transportation in a URL
Safely transporting arbitrary text in URLs requires percent-encoding reserved characters like & and =; Rails helpers do this automatically, while manual URLs need CGI.escape or encodeURIComponent.
Upgrade Rails: Awareness list
Awareness list for Rails upgrades with version-specific pitfalls and workflow references, including production logging changes in Rails 7 and 6.
Capybara: Preventing server errors from failing your test
Capybara can fail tests after all steps when the Rails server raises an error on session cleanup. Filtering known missing-file errors avoids false failures.
Collection of Rails development boosting frameworks
Rails app setup and admin scaffolding can speed up project bootstrapping, data management, and CRUD interfaces with templates and generators.
Rails: namespacing models with table_name_prefix instead of table_name
Rails namespaces can share a table name prefix, avoiding repeated self.table_name settings for each model and keeping nested models aligned with naming conventions.
Maintaining custom application tasks in Rails
Large Rails projects benefit from keeping application tasks slim, separating the executable wrapper from the business code, and testing both rake tasks and scripts.
How to keep using secrets.yml after upgrading to Rails 7.2
Rails 7.2 removes Rails.application.secrets; existing apps can keep secrets.yml by mapping it back with config_for and restoring secret_key_base.
Checklist: Rails Authentication
Authentication is easy to get wrong because most users only sign in once. HTTPS with HSTS and a proven solution like Devise, Clearance or Rails primitives reduce security risks.
Better performance insights with gem `rails_performance`
rails_performance adds low-effort performance monitoring for Rails apps, surfacing slow endpoints, request timing, query breakdowns, and custom events with Redis-backed dashboards.
Rails 3: Sending tempfiles for download
Temporary downloads can fail in Rails 3 when send_file triggers X-Sendfile and the web server cannot read files under /tmp. Using an allowed temp directory avoids 404 errors.
Upgrading a Rails app to Cucumber 3
Rails apps upgrading to Cucumber 3 often need gem updates, new tag syntax, and step-definition fixes to avoid parser and argument-mismatch errors.
How to disable irb's welcome banner or how to enable it for the Rails console
irb 1.18.0 adds a startup banner with version and hint information; it can be hidden or enabled in the Rails console through ~/.irbrc.
Fragment Caching in Rails 7.1+ requires Haml 6
Rails 7.1 changes fragment cache behavior, breaking Haml 5 buffer patches in apps that use caching. Upgrading to Haml 6 is needed for Rails 7.1+ with fragment caching.
Rails: Using normalizes without copying code
Rails 7.1 input cleanup can be reused across models by replacing inline lambdas with callable normalizer classes and a shared base interface.
Using FactoryBot in Development
Dummy development data is faster to create by reusing FactoryBot factories than by using the UI or Rails console records. Defaults, associations, traits, and attribute overrides come along automatically.
How to inspect Rails view cache keys (when using Redis)
Rails view fragments cached in Redis are hard to inspect, but Rails.cache.redis.with(&:keys) can list existing keys. Production keyspaces may be very large.
Ruby / Rails: clone vs. dup vs. deep_dup
Copying Ruby objects can preserve or drop frozen state, singleton methods and mixins, while nested references stay shared unless a true deep copy is used.