Skip to content

Instantly share code, notes, and snippets.

@knoxknox
Created May 3, 2016 16:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save knoxknox/5d8ad010578ca23a99cc4e1cbf409d4d to your computer and use it in GitHub Desktop.
Save knoxknox/5d8ad010578ca23a99cc4e1cbf409d4d to your computer and use it in GitHub Desktop.
##
# cap rails:console
# https://gist.github.com/benedikt/1115513#comment-576015
#
namespace :rails do
desc "Remote console"
task :console, roles: :app do
run_interactively "bundle exec rails console #{rails_env}"
end
end
def run_interactively(command, server=nil)
server ||= find_servers_for_task(current_task).first
exec %Q(ssh -l #{user} #{server} -t 'su - #{user} -c "cd #{current_path} && #{command}"')
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment