From 12b0b26df7560ab5199ba830586864085441508f Mon Sep 17 00:00:00 2001 From: Roque Pinel Date: Sun, 19 Jul 2015 22:00:36 -0400 Subject: Fix state being carried over from previous transaction This clears the transaction record state when the transaction finishes with a `:committed` status. Considering the following example where `name` is a required attribute. Before we had `new_record?` returning `true` for a persisted record: ```ruby author = Author.create! name: 'foo' author.name = nil author.save # => false author.new_record? # => true ``` --- activerecord/CHANGELOG.md | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'activerecord/CHANGELOG.md') diff --git a/activerecord/CHANGELOG.md b/activerecord/CHANGELOG.md index aa2438fb3f..d9aa703d19 100644 --- a/activerecord/CHANGELOG.md +++ b/activerecord/CHANGELOG.md @@ -1,3 +1,17 @@ +* Fix state being carried over from previous transaction. + + Considering the following example where `name` is a required attribute. + Before we had `new_record?` returning `true` for a persisted record: + + author = Author.create! name: 'foo' + author.name = nil + author.save # => false + author.new_record? # => true + + Fixes #20824. + + *Roque Pinel* + * Correctly ignore `mark_for_destruction` when `autosave` isn't set to `true` when validating associations. -- cgit v1.2.3