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..9af549e 100644 --- a/lib/console1984/engine.rb +++ b/lib/console1984/engine.rb @@ -8,6 +8,13 @@ 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. Unless you've explicitly + # said so, we disable the sandboxed console to prevent this issue. + 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)