- Fix bug/inconsistency between
user
andchanged_by
, now withalias_attribute :changed_by, :user
- previously,
audit_tag_with
updates the latest audit if no changes are detected in a record's audited changes. now it creates a new audit row instead because this works better and prevent losing history if we callaudit_tag_with
multiple times. new audits are only created if the combo of 4 attributes is different:modifications
,tag
,user
,action
. - bump minor version because it is more ready for production use at this point
- Add
last_change_of(attribute)
to show the last change that happened to an attribute. Thanks to @zuf
- Fix 'Could not find generator auditable:migration' bug due to a refactoring that moved
generators
out of the/lib
folder. Moved it back
- Only create a new audit if
modifications
differ from last audit
- Fix error when calling
audit_tag_with
on a record without audits and withoutaudit_tag
virtual attribute defined.
.changed_by
,.audit_tag
,.audit_action
virtual attributes are now added to the auditable model by default. The extra checkrespond_to?
on these guys is just cumbersome to carry along.
Easier to explain with code
# Given
>> s = Survey.create :title => "something"
>> s.audits.delete_all
# Before 0.0.5
>> s.audit_tag_with("some tag") # do nothing when no audits exist
>> s.audits.empty? # => true
# From 0.0.5 onwards
>> s.audit_tag_with("some tag") # create an audit with tag if no audits exist
>> s.audits.first.tag == "some tag"