From 6c5763b769a977c96f68008d5b50542f7d472526 Mon Sep 17 00:00:00 2001
From: Sean Griffin <sean@thoughtbot.com>
Date: Fri, 30 May 2014 13:51:27 -0700
Subject: Clear all caches calculated based on `@columns` when `@columns`
 changes

---
 activerecord/lib/active_record/properties.rb | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

(limited to 'activerecord/lib')

diff --git a/activerecord/lib/active_record/properties.rb b/activerecord/lib/active_record/properties.rb
index 21ff906fec..e70f84808d 100644
--- a/activerecord/lib/active_record/properties.rb
+++ b/activerecord/lib/active_record/properties.rb
@@ -75,7 +75,7 @@ module ActiveRecord
       #   store_listing.price_in_cents # => 1000
       def property(name, cast_type, options = {})
         name = name.to_s
-        clear_properties_cache
+        clear_caches_calculated_from_columns
         # Assign a new hash to ensure that subclasses do not share a hash
         self.user_provided_columns = user_provided_columns.merge(name => connection.new_column(name, options[:default], cast_type))
       end
@@ -92,7 +92,7 @@ module ActiveRecord
 
       def reset_column_information # :nodoc:
         super
-        clear_properties_cache
+        clear_caches_calculated_from_columns
       end
 
       private
@@ -108,9 +108,13 @@ module ActiveRecord
         existing_columns + new_columns
       end
 
-      def clear_properties_cache
+      def clear_caches_calculated_from_columns
         @columns = nil
         @columns_hash = nil
+        @column_types = nil
+        @column_defaults = nil
+        @column_names = nil
+        @content_columns = nil
       end
     end
   end
-- 
cgit v1.2.3