ankane / ahoy

Simple, powerful, first-party analytics for Rails
MIT License
4.23k stars 377 forks source link

Fix "uninitialized constant Ahoy::ActiveJob" for Rails applications that do not contain an ActiveJob #530

Closed ts-3156 closed 1 year ago

ts-3156 commented 1 year ago

Hi,

Thank you for this useful gem.

For Rails applications that do not contain an ActiveJob, "uninitialized constant Ahoy::ActiveJob" error will occur. To avoid this error, I have added small code to check if an ActiveJob is already defined before defining an Ahoy::GeocodeV2Job.

Such a Rails application can be created by adding the minimal option to the rails new command (rails new --minimal).

I think this code is not smart. I have no problem if you close this PR and you add your better code. Also, I have already made this modification to my application, so if you think this PR is unnecessary or not for everyone, then feel free to close this PR.

ankane commented 1 year ago

Hi @ts-3156, thanks for reporting and the PR! Changed the job to autoload, which should fix it (however, I wouldn't recommend using master at the moment since it's in flux for Ahoy 5).