Module: AbAdmin::Concerns::HasTracking

Extended by:
ActiveSupport::Concern
Defined in:
lib/ab_admin/concerns/has_tracking.rb

Defined Under Namespace

Modules: ClassMethods

Instance Method Summary collapse

Instance Method Details

#track(options = {}) ⇒ Object


12
13
14
15
16
17
18
19
# File 'lib/ab_admin/concerns/has_tracking.rb', line 12

def track(options={})
  return unless tracking_enabled?
  options[:trackable] ||= self
  options[:owner] ||= user if respond_to?(:user)
  options[:user] ||= updater if respond_to?(:updater)
  options[:key] = [self.class.model_name.plural, options[:key]].compact.join('.')
  tracks.build(options)
end

#track!(*args) ⇒ Object


21
22
23
# File 'lib/ab_admin/concerns/has_tracking.rb', line 21

def track!(*args)
  track(*args).save!
end