Audit saves the changes to ActiveRecord models. It has the following attributes:
auditable
: the ActiveRecord
model that was changed
user
: the user that performed the change; a string or an ActiveRecord model
action
: one of create, update, or delete
audited_changes
: a serialized hash of all the changes
comment
: a comment set with the audit
created_at
: Time that the change was performed
Return all audits older than the current one.
# File lib/audited/adapters/active_record/audit.rb, line 33 def ancestors self.class.where(['auditable_id = ? and auditable_type = ? and version <= ?', auditable_id, auditable_type, version]) end
@private
# File lib/audited/adapters/active_record/audit.rb, line 51 def user_as_string self.user_as_model || self.username end
Allows user to be set to either a string or an ActiveRecord object @private
# File lib/audited/adapters/active_record/audit.rb, line 40 def user_as_string=(user) # reset both either way self.user_as_model = self.username = nil user.is_a?(::ActiveRecord::Base) ? self.user_as_model = user : self.username = user end