Class: Devbin::Commands::Rails::Console

Inherits:
Devbin::Command show all
Defined in:
lib/devbin/commands/rails/console.rb

Instance Method Summary collapse

Methods inherited from Devbin::Command

#command, #cursor, #docker_pwd, #docker_sync_pwd, #editor, #exec_exist?, #find_pwd, #generator, #pager, #pastel, #platform, #prompt, #screen, #which

Constructor Details

#initialize(app_name, options) ⇒ Console

Returns a new instance of Console.



9
10
11
12
# File 'lib/devbin/commands/rails/console.rb', line 9

def initialize(app_name, options)
  @app_name = app_name
  @options = options
end

Instance Method Details

#execute(input: $stdin, output: $stdout) ⇒ Object



14
15
16
17
18
19
20
21
22
23
# File 'lib/devbin/commands/rails/console.rb', line 14

def execute(input: $stdin, output: $stdout)
  Dir.chdir(docker_pwd) do
    pid = Process.fork {
      exec "docker-compose exec #{@app_name} bundle exec rails c"
    }
    Process.wait pid
    output.puts "OK"
    exit 0
  end
end