Debugging

Learn how to debug your app using byebug.

We'll cover the following...

Byebug debugger

No chapter on testing would be complete without some mention of how to debug our application when it is not behaving as we would expect. Imagine there is a problem with our welcome_controller.rb.

Let’s use the byebug debugger that is included as standard with a Rails app. Let’s add a byebug breakpoint to our welcome_controller.rb:

Press + to interact
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

In case your Rails server is up, you need to stop it:

$ docker-compose stop web

When we want an interactive ...