February 2019
Intermediate to advanced
240 pages
5h 25m
English
No chapter on testing would be complete without some mention of how to debug our application when it isn’t behaving as we’d expect.
Imagine there’s a problem with our welcome_controller.rb. Let’s use the byebug debugger that’s included as standard with a Rails app. Let’s add a byebug breakpoint to our welcome_controller.rb:
| | class WelcomeController < ApplicationController |
| | def index |
| | redis = Redis.new(host: "redis", port: 6379) |
| | redis.incr "page hits" |
| | |
| | @page_hits = redis.get "page hits" |
| » | byebug |
| | end |
| | end |
Let’s stop our Rails server:
| | $ docker-compose stop web |
When we want an interactive session with a container, rather than using docker-compose up, we instead use docker-compose run. Let’s ...
Read now
Unlock full access