Reputation: 6320
Byebug with ActiveRecord in Rails 6 is not logging as expected in my test environment.
When I run a test and use byebug to pause execution ActiveRecord is not logging queries to the console. For example, if I type Candidate.second
I see no SQL output:
What I would like to see, and what I do see if I run the same query in my development environment within the rails console:
I've looked through documentation on both ActiveRecord and ByeBug but can't seem to solve this. Any help is appreciated!
Throw a debugger statement into a controller, and run a test:
ActiveRecord is not logging queries into the console when using byebug. For example, if a run a test that hits a controller action:
class JobsController < ApplicationController
# ...
def show
debugger
Candidate.first # arbitrary query
render json: @job
end
end
From the terminal:
rails test test/controllers/jobs_controller.rb
Upvotes: 2
Views: 600
Reputation: 366
ActiveRecord::Base.logger = Logger.new(STDOUT)
Not sure why it doesn't come by default or how to make it permanent. You have to enable rails logger in the byebug console as well.
Upvotes: 4