Use create bang method for version creation on 'create' events so that an exception gets raised when sensible. Fix #207

This commit is contained in:
Ben Atkins 2013-08-08 16:23:02 -04:00
parent a91d56cd74
commit 4f00933afd
2 changed files with 3 additions and 2 deletions

View File

@ -4,6 +4,8 @@
Fixed compatibility with [ActsAsTaggableOn](https://github.com/mbleigh/acts-as-taggable-on).
- [#235](https://github.com/airblade/paper_trail/pull/235) - Dropped unnecessary secondary sort on `versions` association.
- [#212](https://github.com/airblade/paper_trail/pull/212) - Added `PaperTrail::Cleaner` module, useful for discarding draft versions.
- [#207](https://github.com/airblade/paper_trail/issues/207) - Versions for `'create'` events are now created with `create!` instead of
`create` so that an exception gets raised if it is appropriate to do so.
- [#199](https://github.com/airblade/paper_trail/pull/199) - Rails 4 compatibility.
- [#165](https://github.com/airblade/paper_trail/pull/165) - Namespaced the version class under the `PaperTrail` module.

View File

@ -201,8 +201,7 @@ module PaperTrail
if changed_notably? and version_class.column_names.include?('object_changes')
data[:object_changes] = PaperTrail.serializer.dump(changes_for_paper_trail)
end
send(self.class.versions_association_name).create merge_metadata(data)
send(self.class.versions_association_name).create! merge_metadata(data)
end
end