Module: Auditrail::ClassMethods
- Defined in:
- lib/auditrail.rb,
lib/audit_options.rb
Defined Under Namespace
Classes: AuditOptions
Instance Method Summary collapse
Instance Method Details
#auditable(&block) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/auditrail.rb', line 14 def auditable(&block) = block ? AuditOptions.new(&block) : AuditOptions.new class_eval do before_create do track_changes(:creating, .user) if attributes_changed?(*.attributes) end before_update do track_changes(:updating, .user) if attributes_changed?(*.attributes) end after_save do save_tracked_changes if attributes_changed?(*.attributes) end end end |