From 93ee9f0cba607f1050610cddcfa509e5faa7e731 Mon Sep 17 00:00:00 2001
From: Aaron Patterson <aaron.patterson@gmail.com>
Date: Thu, 12 Dec 2013 11:31:11 -0800
Subject: remove more nil checks

---
 .../lib/active_record/associations/belongs_to_association.rb  | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

(limited to 'activerecord')

diff --git a/activerecord/lib/active_record/associations/belongs_to_association.rb b/activerecord/lib/active_record/associations/belongs_to_association.rb
index 7d96f0c372..7dc817fc66 100644
--- a/activerecord/lib/active_record/associations/belongs_to_association.rb
+++ b/activerecord/lib/active_record/associations/belongs_to_association.rb
@@ -8,17 +8,16 @@ module ActiveRecord
       end
 
       def replace(record)
-        raise_on_type_mismatch!(record) if record
-
-        update_counters(record)
         if record
+          raise_on_type_mismatch!(record)
+          update_counters(record)
           replace_keys(record)
+          set_inverse_instance(record)
+          @updated = true
         else
+          update_counters(record)
           remove_keys
         end
-        set_inverse_instance(record) if record
-
-        @updated = true if record
 
         self.target = record
       end
-- 
cgit v1.2.3