Cleaning up code in :item_before_change method on PaperTrail::Model::InstanceMethods; update CHANGELOG

This commit is contained in:
Ben Atkins 2013-10-03 10:43:19 -04:00
parent 35d574ff8b
commit 41d1b5cd65
2 changed files with 3 additions and 2 deletions

View File

@ -1,5 +1,6 @@
## 3.0.0 (Unreleased)
- [#280](https://github.com/airblade/paper_trail/pull/280) - Don't track virtual timestamp attributes.
- [#278](https://github.com/airblade/paper_trail/issues/278)/[#272](https://github.com/airblade/paper_trail/issues/272) -
Make RSpec and Cucumber helpers usable with [Spork](https://github.com/sporkrb/spork) and [Zeus](https://github.com/burke/zeus).
- [#273](https://github.com/airblade/paper_trail/pull/273) - Make the `only` and `ignore` options accept `Hash` arguments;

View File

@ -268,10 +268,10 @@ module PaperTrail
previous = self.dup
# `dup` clears timestamps so we add them back.
all_timestamp_attributes.each do |column|
previous[column] = send(column) if attributes.has_key?(column.to_s) && !send(column).nil?
previous[column] = send(column) if self.class.column_names.include?(column.to_s) and not send(column).nil?
end
previous.tap do |prev|
prev.id = id
prev.id = id # `dup` clears the `id` so we add that back
changed_attributes.select { |k,v| self.class.column_names.include?(k) }.each { |attr, before| prev[attr] = before }
end
end