From 9deb6ababe87393fb7806c5097faf51f2852deda Mon Sep 17 00:00:00 2001 From: Sean Griffin Date: Sat, 7 Nov 2015 08:17:25 -0700 Subject: Ensure `#reset_column_information` clears child classes as well I've added a redundant test for this under the attributes API as well, as that also causes this bug to manifest through public API (and demonstrates that calling `reset_column_information` on the child classes would be insufficient) Since children of a class should always share a table with their parent, just reloading the schema from the cache should be sufficient here. `reload_schema_from_cache` should probably become public and `# :nodoc:`, but I'd rather avoid the git churn here. Fixes #22057 --- activerecord/lib/active_record/model_schema.rb | 3 +++ 1 file changed, 3 insertions(+) (limited to 'activerecord/lib/active_record/model_schema.rb') diff --git a/activerecord/lib/active_record/model_schema.rb b/activerecord/lib/active_record/model_schema.rb index a9bd094a66..e3f304b0af 100644 --- a/activerecord/lib/active_record/model_schema.rb +++ b/activerecord/lib/active_record/model_schema.rb @@ -339,6 +339,9 @@ module ActiveRecord @columns = nil @columns_hash = nil @attribute_names = nil + direct_descendants.each do |descendant| + descendant.send(:reload_schema_from_cache) + end end # Guesses the table name, but does not decorate it with prefix and suffix information. -- cgit v1.2.3