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

Adding Userstamp in mongoid 5 #148

Open
sahilchopra opened this issue Mar 27, 2016 · 4 comments
Open

Adding Userstamp in mongoid 5 #148

sahilchopra opened this issue Mar 27, 2016 · 4 comments
Labels

Comments

@sahilchopra
Copy link

HI

Mongoid_userstamp Gem is not working with mongoid5. ( nosolosoftware/mongoid_userstamp#27) Do we have any alternative to store user_id when we create HistoryTracker object?

Thanks

@yads
Copy link
Contributor

yads commented Mar 21, 2017

I wound up rolling my own based on mongoid_userstamps. Added

class HistoryTracker
  include Mongoid::History::Tracker

  before_create :set_modifier

  protected

  def set_modifier
    self.modifier = Auditing.current_user
  end
end

class Auditing
  class << self
    def current_user
      Thread.current['auditing:current_user']
    end

    def current_user=(user)
      Thread.current['auditing:current_user'] = user
    end
  end
end

Then added a before_filter in my ApplicationController that set the Auditing.current_user to the current_user from devise.

@dblock
Copy link
Collaborator

dblock commented Jun 20, 2018

We still recommend the userstamp gem while it hasn't been supported since mongoid 4. Maybe someone cares to remove it from the documentation altogether or suggest an alternative?

@jclusso
Copy link

jclusso commented Dec 10, 2024

Any update on this? The documentation still suggests we use a gem that is no longer maintained or supported for over 5 years.

@dblock
Copy link
Collaborator

dblock commented Dec 10, 2024

No updates @jclusso, want to help?

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

No branches or pull requests

4 participants