Module: Auditing::Base
- Defined in:
- lib/auditing/base.rb
Defined Under Namespace
Modules: InstanceMethods
Instance Method Summary collapse
-
#audit_enabled(opts = {}) ⇒ Object
Auditing creates audit objects for a record.
- #gather_fields_for_auditing(fields = nil) ⇒ Object
Instance Method Details
#audit_enabled(opts = {}) ⇒ Object
Auditing creates audit objects for a record.
13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/auditing/base.rb', line 13 def audit_enabled(opts={}) include InstanceMethods class_inheritable_accessor :auditing_fields has_many :audits, :as => :auditable, :order => 'created_at DESC, id DESC' self.auditing_fields = gather_fields_for_auditing(opts[:fields]) after_create :log_creation after_update :log_update end |
#gather_fields_for_auditing(fields = nil) ⇒ Object
25 26 27 28 |
# File 'lib/auditing/base.rb', line 25 def gather_fields_for_auditing(fields=nil) return self.column_names - ["id", "created_at", "updated_at"] unless fields fields.is_a?(Array) ? fields.map {|f| f.to_s} : [fields.to_s] end |