Search code examples
mongoidruby-on-rails-5delayed-jobrails-activejobahoy

Rails serialization error for async geocoding with ahoy gem using mongoid


I have a Rails 5 app, running both a postgresql DB for application data and MongoDB (mongoid) for analytics, generated by the fantastic ahoy gem.

Everything works great until I switch to asynchronous geocoding in config/initializers/ahoy.rb, which generates the error below:

ActiveJob::SerializationError (Unsupported argument type: Visit):

The app is using delayed_job, for background processing.

I there a workaround for this issue, or is this caused by incompatibility between mongoid and delayed_job?


Solution

  • Try adding the GlobalId mixin to your model

    class Visit
      include GlobalID::Identification
    end