Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add an option to start rails console in sandbox mode by default #48984

Merged
merged 1 commit into from Aug 22, 2023

Conversation

shouichi
Copy link
Contributor

To avoid accidental writing to the production database, I always start rails console in sandbox mode. I only start rails console in non-sandbox mode when I'm sure I want to write to the production database.

sandbox_by_default option is added to start rails console in sandbox mode by default. With this option turned on, --no-sandbox must be specified to start rails in non-sandbox mode.

Note that this option is ignored when rails environment is development or test.

@rafaelfranca
Copy link
Member

Tests are broken. Can you take a look?



Error:
--
  | Rails::ConsoleTest#test_console_with_environment:
  | NoMethodError: undefined method `sandbox_by_default' for #<#<Class:0x00005641ca0fe940>:0x00005641ca0fe670>
  | test/commands/console_test.rb:161:in `new'
  | test/commands/console_test.rb:161:in `start'
  | test/commands/console_test.rb:52:in `test_console_with_environment'
  |  
  |  
  | bin/rails test test/commands/console_test.rb:51

To avoid accidental writing to the production database, I always start
rails console in sandbox mode. I only start rails console in non-sandbox
mode when I'm sure I want to write to the production database.

`sandbox_by_default` option is added to start rails console in sandbox
mode by default. With this option turned on, `--no-sandbox` must be
specified to start rails in non-sandbox mode.

Note that this option is ignored when rails environment is development
or test.
@shouichi
Copy link
Contributor Author

@rafaelfranca Fixed the tests. Could you take a look?

@rafaelfranca rafaelfranca merged commit 9b6dee0 into rails:main Aug 22, 2023
9 checks passed
@shouichi shouichi deleted the sandbox-by-default branch August 22, 2023 01:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants