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

undefined method `criteria' for class PublicActivity::Activity using MongoID #390

Open
jakepham90 opened this issue Aug 2, 2024 · 3 comments

Comments

@jakepham90
Copy link

I got an undefined method when trying to create an object that is currently being tracked while using Mongoid.
Using Rails 7.1.3
Ruby 3.3.3
public_activity the latest version.
Screenshot 2024-08-02 at 6 08 45 AM

class Lead
include Mongoid::Document
include PublicActivity::Model
tracked
belongs_to :user
has_many :lead_messages
has_many :campaign_user_lists
accepts_nested_attributes_for :lead_messages

@ur5us
Copy link
Collaborator

ur5us commented Oct 3, 2024

@jakepham90 Indeed, there’s no such method defined by the gem. It could be our outdated Mongo integration. I just had a quick look at the Mongoid gem and #criteria is seems to be used in many places there. Could you try to submit a PR?

@netik
Copy link

netik commented Jan 8, 2025

I have the same issue here and I'm trying to understand where this is coming from as well. #criteria is the generic mongoid db (select) criteria as far as I know but it seems to be firing on save. Perhaps the mongoid code is trying to read the model but it's hard to tell. Comment if you've found a solution. I'm trying to get this working on Rails 8 with Mongoid.

@netik
Copy link

netik commented Jan 8, 2025

I managed to partially fix this by monkey patching PublicActivity like this, in the initializer.

At least now I can access the Activity model again from my app.

# config/initializers/public_activity.rb
PublicActivity::Config.set do
  orm :mongoid
end

module PublicActivity
  class Activity < inherit_orm("Activity")
  end
end

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