How to enter rails console on production via capistrano?

前端 未结 7 1499
借酒劲吻你
借酒劲吻你 2021-02-02 11:25

I want to enter the rails console on production server from my local machine via capistrano. I found some gists, e.g. https://gist.github.com/813291 and when I enter console via

7条回答
  •  遥遥无期
    2021-02-02 11:45

    I've added my own tasks for this kind of thing:

    namespace :rails do
      desc "Remote console"
      task :console, :roles => :app do
        run_interactively "bundle exec rails console #{rails_env}"
      end
    
      desc "Remote dbconsole"
      task :dbconsole, :roles => :app do
        run_interactively "bundle exec rails dbconsole #{rails_env}"
      end
    end
    
    def run_interactively(command)
      server ||= find_servers_for_task(current_task).first
      exec %Q(ssh #{user}@#{myproductionhost} -t '#{command}')
    end
    

    I now say cap rails:console and get a console.

提交回复
热议问题