Created
October 30, 2012 22:12
-
-
Save adzap/3983423 to your computer and use it in GitHub Desktop.
Add transaction ID to audit records
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Using XID gem https://github.com/adzap/xid | |
# with Audited gem https://github.com/collectiveidea/audited/commits/master | |
# This adds the transaction ID to the audit record so you can group all changes together which happened in the same transaction, # which is hopefully the same use action. This obviously needs you add a transaction_id column to the audits table. | |
Audited::Adapters::ActiveRecord::Audit.class_eval do | |
before_create :set_transaction_id | |
def set_transaction_id | |
self.transaction_id = ActiveRecord::Base.connection.transaction_id | |
nil | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment