joshmn / ahoy_captain

A full-featured, mountable analytics dashboard for your Rails app, powered by the Ahoy gem.
MIT License
356 stars 18 forks source link

Issues while trying app #1

Open woodhull opened 1 year ago

woodhull commented 1 year ago
AhoyCaptain.configure 

should be

AhoyCaptain.configure do |config|
    NoMethodError:
       Could not render layout: undefined method `headers' for nil:NilClass
     # /usr/local/bundle/gems/turbo-rails-1.4.0/app/controllers/turbo/frames/frame_request.rb:34:in `turbo_frame_request_id'
     # /usr/local/bundle/gems/turbo-rails-1.4.0/app/controllers/turbo/frames/frame_request.rb:30:in `turbo_frame_request?'
     # /usr/local/bundle/gems/turbo-rails-1.4.0/app/controllers/turbo/frames/frame_request.rb:24:in `block (2 levels) in <module:FrameRequest>'
     # ./app/sidekiq/add_card_to_stage.rb:11:in `perform'

I'm not clear on why adding the ahoy_captain gem causes turbo gem code to be called outside of the engine itself.

joshmn commented 1 year ago

Ah that's a weird one! The turbo thing, at least — I do need to update the configuration file (this was made hastily in a recent railshackathon.com-thon).

I think this might be happening from one of your background jobs indeed. How are you rendering the templates? Are you using ApplicationController.render or perhaps render_to_string? Curious to see add_card_to_stage.rb and if you're invoking any callbacks before render.

There are a pair of callbacks that are invoked by AhoyCaptain that check if the request is a turbo request or one that it could handle: https://github.com/joshmn/ahoy_captain/blob/main/app/controllers/ahoy_captain/application_controller.rb#L31 (also L38)

If you can provide some insight to those I can probably track this down fairly quickly :)