Class: ActionAudit::Ar::UpdateObserver
- Inherits:
-
Object
- Object
- ActionAudit::Ar::UpdateObserver
- Includes:
- Singleton
- Defined in:
- lib/action_audit/ar.rb
Instance Method Summary collapse
Instance Method Details
#after_commit(record) ⇒ Object
5 6 7 8 9 10 11 12 13 14 |
# File 'lib/action_audit/ar.rb', line 5 def after_commit(record) changes = record.previous_changes if changes.present? was = Hash[changes.map{|key, value| [key, value.first]}] become = Hash[changes.map{|key, value| [key, value.last]}] ActionAudit.add_change(record, was, become) end rescue Exception => e ActionAudit.error(e) end |