-
Notifications
You must be signed in to change notification settings - Fork 57
Open
Description
I think this might be related with the other 2 issues you have open in this gem, but I had a long debugging session till I found out that unless you explicitly add the mongoid_userstamp_user call on the model where you want to use the userstamps, the gem won't be applied to the model if you just use:
include Mongoid::Userstamp
as the readme implies in the first example.
I'm using the gem in combination with https://github.com/aq1018/mongoid-history . I'm using the following gemset (short version):
gem 'rails', '4.1.8'
# Mongoid
gem 'mongoid', github: 'mongoid/mongoid'
gem 'mongoid_slug', github: 'digitalplaywright/mongoid-slug'
gem 'mongoid-history'
gem 'mongoid_userstamp'
# Users & Policies
gem 'devise', '~> 3.4.0'
gem 'devise-encryptable', '~> 0.2.0'
gem 'devise_invitable', github: 'scambra/devise_invitable'
gem 'devise-scrypt'
gem 'pundit'
gem 'enumerize'
......
Using Ruby 2.1.4
My models (reduced version) are as follows:
#The model used for HistoryTracker gem
class HistoryTracker
include Mongoid::History::Tracker
include Mongoid::Userstamp
mongoid_userstamp #Gem won't work unless I add this line explicitly
end
class User
include Mongoid::Document
include Mongoid::Userstamp::User
include Mongoid::Attributes::Dynamic
include Mongoid::Timestamps
extend Enumerize
has_and_belongs_to_many :accounts
devise :invitable, :encryptable, :database_authenticatable, :registerable, :lockable,
:recoverable, :confirmable, :rememberable, :trackable, :validatable, :timeoutable
end
class Model1
include Mongoid::Document
include Mongoid::Attributes::Dynamic
include Mongoid::Timestamps
include Mongoid::History::Trackable
belongs_to :account
track_history track_create: true
end
class Account
include Mongoid::Document
include Mongoid::Attributes::Dynamic
include Mongoid::Timestamps
include Mongoid::History::Trackable
include Mongoid::Slug
has_and_belongs_to_many :users
track_history on: [:filing_frequency, :status] #log account changes
end
I think the issue is with the default call to mongoid_userstamp, which for some reason doesn't happen as expected.
Metadata
Metadata
Assignees
Labels
No labels