Skip to content

Instantly share code, notes, and snippets.

@terrcin
Last active August 29, 2015 14:17
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save terrcin/0745f2c6240aad291077 to your computer and use it in GitHub Desktop.
Save terrcin/0745f2c6240aad291077 to your computer and use it in GitHub Desktop.
Granting readonly access to rails production console by default
# 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