Class: Audited::Adapters::ActiveRecord::Audit
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Audited::Adapters::ActiveRecord::Audit
- Includes:
- ActiveModel::Observing, Audited::Audit
- Defined in:
- lib/audited/adapters/active_record/audit.rb
Overview
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 -
version
: the version of the model -
request_uuid
: a uuid based that allows audits from the same controller request -
created_at
: Time that the change was performed
Instance Method Summary collapse
-
#ancestors ⇒ Object
Return all audits older than the current one.
- #user_as_string ⇒ Object (also: #user)
-
#user_as_string=(user) ⇒ Object
(also: #user=)
Allows user to be set to either a string or an ActiveRecord object.
Instance Method Details
#ancestors ⇒ Object
Return all audits older than the current one.
35 36 37 38 |
# File 'lib/audited/adapters/active_record/audit.rb', line 35 def ancestors self.class.where(['auditable_id = ? and auditable_type = ? and version <= ?', auditable_id, auditable_type, version]) end |
#user_as_string ⇒ Object Also known as: user
53 54 55 |
# File 'lib/audited/adapters/active_record/audit.rb', line 53 def user_as_string self.user_as_model || self.username end |
#user_as_string=(user) ⇒ Object Also known as: user=
Allows user to be set to either a string or an ActiveRecord object
42 43 44 45 46 47 48 |
# File 'lib/audited/adapters/active_record/audit.rb', line 42 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 |