aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record
diff options
context:
space:
mode:
authorArthur Neves <arthurnn@gmail.com>2014-03-10 11:37:33 -0400
committerArthur Neves <arthurnn@gmail.com>2014-03-10 14:10:46 -0400
commite5f15a83656f6d005dab40a30fb9f7fa2cf65d77 (patch)
tree38ccec5cb4629dc56ea1d5558b1a1f13b06040a3 /activerecord/lib/active_record
parent6e3ab3e15faf782f6a937ccf5574a4fb63e3e353 (diff)
downloadrails-e5f15a83656f6d005dab40a30fb9f7fa2cf65d77.tar.gz
rails-e5f15a83656f6d005dab40a30fb9f7fa2cf65d77.tar.bz2
rails-e5f15a83656f6d005dab40a30fb9f7fa2cf65d77.zip
Fixes STI when 2+ levels deep.
PR #14052 Added a regression where it was only looking for methods in one level up, So when the method was defined in a 2+ levels up the inheritance chain, the method was not found as defined.
Diffstat (limited to 'activerecord/lib/active_record')
-rw-r--r--activerecord/lib/active_record/attribute_methods.rb6
1 files changed, 3 insertions, 3 deletions
diff --git a/activerecord/lib/active_record/attribute_methods.rb b/activerecord/lib/active_record/attribute_methods.rb
index 57ceec2fc5..ea48a13ea8 100644
--- a/activerecord/lib/active_record/attribute_methods.rb
+++ b/activerecord/lib/active_record/attribute_methods.rb
@@ -105,9 +105,9 @@ module ActiveRecord
super
else
# If B < A and A defines its own attribute method, then we don't want to overwrite that.
- defined = method_defined_within?(method_name, superclass) &&
- superclass.instance_method(method_name).owner != superclass.generated_attribute_methods
- defined || super
+ defined = method_defined_within?(method_name, superclass, superclass.generated_attribute_methods)
+ base_defined = Base.method_defined?(method_name) || Base.private_method_defined?(method_name)
+ defined && !base_defined || super
end
end