Is there a way to use capistrano (or similar) to remotely interact with rails console

I'm loving how capistrano has simplified my deployment workflow, but often times a pushed change will run into issues that I need to log into the server to troubleshoot via the console.

Is there a way to use capistrano or another remote administration tool to interact with the rails console on a server from your local terminal?


cap shell seems promising, but it hangs when you try to start the console:

cap> cd /path/to/application/current
cap> pwd
 ** [out ::] /path/to/application/current
cap> rails c production
 ** [out ::] Loading production environment (Rails 3.0.0)
 ** [out ::] Switch to inspect mode.

if you know a workaround for this, that'd be great


I found pretty nice solution based on

desc "Remote console" 
task :console, :roles => :app do
  env = stage || "production"
  server = find_servers(:roles => [:app]).first
  run_with_tty server, %W( ./script/rails console #{env} )

desc "Remote dbconsole" 
task :dbconsole, :roles => :app do
  env = stage || "production"
  server = find_servers(:roles => [:app]).first
  run_with_tty server, %W( ./script/rails dbconsole #{env} )

def run_with_tty(server, cmd)
  # looks like total pizdets
  command = []
  command += %W( ssh -t #{gateway} -l #{self[:gateway_user] || self[:user]} ) if     self[:gateway]
  command += %W( ssh -t )
  command += %W( -p #{server.port}) if server.port
  command += %W( -l #{user} #{} )
  command += %W( cd #{current_path} )
  # have to escape this once if running via double ssh
  command += [self[:gateway] ? '\&\&' : '&&']
  command += Array(cmd)
  system *command

Need Your Help

Breakpoint set with IntelliJ not working in premain of remote custom java agent

java debugging intellij-idea agent

I've started to implement a simple Java agent that does some instrumentation before a class is loaded by JVM. The thing is I need to do some debugging on this agent, but what I tried so far had fai...

update progress for ASP:Button

javascript jquery

I want to use show a "Loading Image" on the click of server side button, that should be unloaded after the button event completes.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.