Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Seeing undefined method `adapter_name' for ActiveJob:Module #20

Closed
obromios opened this issue Mar 8, 2024 · 6 comments
Closed

Seeing undefined method `adapter_name' for ActiveJob:Module #20

obromios opened this issue Mar 8, 2024 · 6 comments

Comments

@obromios
Copy link

obromios commented Mar 8, 2024

This looks like a very good idea, however, when I install it according to the instructions I get the following exception on page load

NoMethodError at /myhome
undefined method `adapter_name' for ActiveJob:Module

and the exception occurs at this line in a before_action in my application controller

EventTrackingJob.perform_later(name: "Visited #{controller_name}##{action_name}", user_id: visitor_id)

@raihanM99
Copy link

raihanM99 commented Mar 9, 2024

I've encountered a similar error with the adapter_name method. It occurs when I send a deliver_later email, with the traceback only showing in the controller where I invoke the email sending. My project is running on Rails 7.0.4 with Sidekiq as the queue adapter.

 undefined method adapter_name for ActiveJob.adapter_name(event.payload[:adapter])

Upon reviewing the gems, I've pinpointed the issue within the private methods of lib/debugbar/subscribers/active_job.rb.

def queue_name(event)
  ActiveJob.adapter_name(event.payload[:adapter]) + "(#{event.payload[:job].queue_name})"
end

I couldn't find anything about ActiveJob#adapter_name despite checking the Rails docs and the internet. So, I tried changing it like this.

def queue_name(event)
  "(#{event.payload[:job].queue_name})"
end

Maybe it's a bit risky to avoid the error this way (at least until the new fixes). You could simply disable the feature in the initializer instead.

Debugbar.configure do |config|
  config.active_job = false
end

@julienbourdeau
Copy link
Owner

julienbourdeau commented Mar 17, 2024

Thank you @obromios for the report and @raihanM99 for digging! 🙏

The queue_name method was directly copied from Rails but I didn't realize that ActiveJob.adapter_name was only added recently!

I have started a fix that I'm hoping to publish this week: #24

@obromios
Copy link
Author

Thank you for fixing this. I tried to test it with the master branch, but saw an exception with this explanation

debugbar_javascript was removed in 0.3.0.
Please use `debugbar_head` inside <head> and `debugbar_body(opt_hash)` at the end of <body> instead.
It was split to support Turbo Drive.
See https://debugbar.dev/changelog/ for more information.

I tried putting it <%= debugbar_body(opt_hash) %> into the body, but opt_hash in not defined. Maybe it is now a configuration option? I checked the changelog and it did not contain any more information and the current documentation has not been updated for the Turbo drive release. I apologise if you were planning to fix this for the next gem release.

@obromios
Copy link
Author

I also note that the documentation for the action cable configuration has Algolia::Application.configure whereas I was expecting to see Rails.application.configure for development.rb

@julienbourdeau
Copy link
Owner

julienbourdeau commented Mar 31, 2024

Thank you for testing so fast @obromios 😄 I have released 0.3.0 and updated the docs. The error message was meant to say "this is where you put your config if you have any" but you're right it wasn't clear. I updated the error message before the release 🙏

You can use debugbar_body alone or pass it some config hash debugbar_body height: 740.

The documentation was fully updated!

I also removed the mention of Algolia instead of Rails. At the time, I was working at Algolia and copy pasted the config from the app 😄

@obromios
Copy link
Author

obromios commented Apr 1, 2024

I have tried 0.3.0 and the documentation is up to date, and it all works well. Thank you for this useful utility.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants