Last active
August 29, 2015 14:17
-
-
Save terrcin/0745f2c6240aad291077 to your computer and use it in GitHub Desktop.
Granting readonly access to rails production console by default
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# In our config/deploy.rb we have the below for an easy prod console. | |
# There are various ways of doing it. | |
desc "Remote console" | |
task :console, roles: :app do | |
server = find_servers(roles: [:app]).first | |
run_with_tty server, %W( ./script/rails console #{rails_env} ) | |
end | |
# Turns out there is a '--sandbox' option for the console that will roll back any changes on exit | |
# http://guides.rubyonrails.org/command_line.html#rails-console | |
# So we can do this: | |
desc "Remote console" | |
task :console, roles: :app do | |
server = find_servers(roles: [:app]).first | |
cmd = %W( ./script/rails console #{rails_env} ) | |
cmd << '--sandbox' unless ENV['PRODUCTION'] == 'readwrite' | |
run_with_tty server, cmd | |
end | |
# Why? you have to set the ENV var if you want to actually make changes, so an extra step. | |
# Also we're constantly looking up stuff on prod console to investigate support tickets | |
# and I want junior team member to be able to investigate knowing they can't break anything | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment