From b7cce1c0a92ef88341137290eefd19ef688c175b Mon Sep 17 00:00:00 2001 From: Sean Griffin Date: Thu, 14 Jan 2016 13:31:02 -0700 Subject: Ensure enum scopes work properly with STI and inheritance The code was changed to call `where` on a specific class in 813c8c07, but no reasoning was given and I can't see any good reason why we would need to do that. This will ensure that the method is called on whatever class the scope is called on. Fixes #23013 --- activerecord/lib/active_record/enum.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/activerecord/lib/active_record/enum.rb b/activerecord/lib/active_record/enum.rb index 04519f4dc3..8655f68308 100644 --- a/activerecord/lib/active_record/enum.rb +++ b/activerecord/lib/active_record/enum.rb @@ -187,7 +187,7 @@ module ActiveRecord # scope :active, -> { where status: 0 } klass.send(:detect_enum_conflict!, name, value_method_name, true) - klass.scope value_method_name, -> { klass.where name => value } + klass.scope value_method_name, -> { where(name => value) } end end defined_enums[name.to_s] = enum_values -- cgit v1.2.3