aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib
diff options
context:
space:
mode:
authorMichael Koziarski <michael@koziarski.com>2008-01-26 06:23:03 +0000
committerMichael Koziarski <michael@koziarski.com>2008-01-26 06:23:03 +0000
commitc48f744400844e4c73eb91c83d86c3e915a9d78b (patch)
tree4ab9aab31349aebaeff17181d1170fdbcc486ebe /activerecord/lib
parent02625c9c962a868ee7d1a0903d5aaead290ec0ef (diff)
downloadrails-c48f744400844e4c73eb91c83d86c3e915a9d78b.tar.gz
rails-c48f744400844e4c73eb91c83d86c3e915a9d78b.tar.bz2
rails-c48f744400844e4c73eb91c83d86c3e915a9d78b.zip
Make sure that belongs_to counter decrements when assigning nil Closes #10804 [jeanmartin]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@8735 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activerecord/lib')
-rw-r--r--activerecord/lib/active_record/associations/belongs_to_association.rb2
1 files changed, 1 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/associations/belongs_to_association.rb b/activerecord/lib/active_record/associations/belongs_to_association.rb
index 1752678cbd..f5557618c4 100644
--- a/activerecord/lib/active_record/associations/belongs_to_association.rb
+++ b/activerecord/lib/active_record/associations/belongs_to_association.rb
@@ -13,7 +13,7 @@ module ActiveRecord
counter_cache_name = @reflection.counter_cache_column
if record.nil?
- if counter_cache_name && @owner[counter_cache_name] && !@owner.new_record?
+ if counter_cache_name && !@owner.new_record?
@reflection.klass.decrement_counter(counter_cache_name, @owner[@reflection.primary_key_name]) if @owner[@reflection.primary_key_name]
end