console-safety-production
Console Safety in Production
The production Rails console is a foot-gun.
User.update_all(admin: true)runs in 0.2 seconds. There is no undo. This skill encodes the habits, gates, and alternatives that keep production console operations safe.
The opinion
Avoid the production console for routine work — write a rake task or a script-as-PR. When you must use it, default to read-only mode. Use
rails console --sandboxfor any state-changing exploration. Enable Rails 7.2+ production console warning. Log every session. Never runupdate_all/delete_all/truncate/ raw SQL DML in console.
Why it matters: most "production outage caused by a 1-line typo" incidents trace back to console usage. The console gives you full ActiveRecord power with zero review, zero tests, zero rollback.
Pattern 1: Production console warning (Rails 7.2+)
Rails 7.2 shipped the production console warning by default. IRB renders a prominent prompt with the environment name when launched against production, e.g.:
Loading production environment (Rails 8.0.0)
production> User.first