From 974b5d70d2e0e98c2828678c856e7ad7edf250bd Mon Sep 17 00:00:00 2001 From: Alex Date: Wed, 14 Feb 2024 11:41:53 +1000 Subject: [PATCH] Disable the Rails sandbox console --- README.md | 4 ++++ lib/console1984/engine.rb | 6 ++++++ 2 files changed, 10 insertions(+) diff --git a/README.md b/README.md index 76ad901..a742fcb 100644 --- a/README.md +++ b/README.md @@ -139,6 +139,10 @@ By default, sessions will be incinerated with a job 30 days after they are creat When starting a console session, `console1984` will eager load all the application classes if necessary. In practice, production environments already load classes eagerly, so this won't represent any change for those. +## `rails console --sandbox` + +`console1984` will disable the Rails sandbox console, becuase it's not able to record sessions while in sandbox mode. + ## Configuration These config options are namespaced in `config.console1984`: diff --git a/lib/console1984/engine.rb b/lib/console1984/engine.rb index da99444..e5295c5 100644 --- a/lib/console1984/engine.rb +++ b/lib/console1984/engine.rb @@ -8,6 +8,12 @@ class Engine < ::Rails::Engine config.console1984.protected_environments ||= %i[ production ] config.console1984.protected_urls ||= [] + # Console 1984 doesn't work with the sandboxed Rails console, becuase + # it can't write its audit entries to the database. + initializer "console1984.disable_sandbox" do |app| + app.config.disable_sandbox = true + end + initializer "console1984.config" do config.console1984.each do |key, value| Console1984.config.send("#{key}=", value)