Created
April 24, 2015 14:45
-
-
Save seajoshc/db76bf59c6f4dd1d6ed6 to your computer and use it in GitHub Desktop.
Remote Rails Console cap 2 task
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
namespace :rails do | |
desc 'Remote rails console' | |
task :console, roles: :app do | |
run_interactively "rails console #{rails_env}" | |
end | |
desc 'Remote dbconsole' | |
task :dbconsole, roles: :app do | |
run_interactively "rails dbconsole #{rails_env}" | |
end | |
def run_interactively(command) | |
server ||= find_servers_for_task(current_task).first | |
puts " running `#{command}` #{server}" | |
exec %(ssh #{server} -t "cd #{deploy_to}/current && sudo #{command}") | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment