Sha256: 291b45949acbc2cbe7deebd9ba948db42a2465f224f165f3753e449cb0a8399a
Contents?: true
Size: 804 Bytes
Versions: 2
Compression:
Stored size: 804 Bytes
Contents
module AbAdmin module Concerns module HasTracking extend ActiveSupport::Concern included do has_many :tracks, as: :trackable class_attribute :tracking_enabled self.tracking_enabled = true end 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 def track!(*args) track(*args).save! end module ClassMethods def tracking_enabled? tracking_enabled && Activity.tracking_enabled end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
ab_admin-0.5.0 | lib/ab_admin/concerns/has_tracking.rb |
ab_admin-0.4.0 | lib/ab_admin/concerns/has_tracking.rb |