aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/enum.rb
diff options
context:
space:
mode:
authorSean Griffin <sean@seantheprogrammer.com>2016-01-14 13:31:02 -0700
committerSean Griffin <sean@seantheprogrammer.com>2016-01-14 13:31:10 -0700
commitb7cce1c0a92ef88341137290eefd19ef688c175b (patch)
treeb4aa98fa9f27078acb0d6548ec24d0cf69229c83 /activerecord/lib/active_record/enum.rb
parent5854de38859fd770702c41747576d5c86c82d4b9 (diff)
downloadrails-b7cce1c0a92ef88341137290eefd19ef688c175b.tar.gz
rails-b7cce1c0a92ef88341137290eefd19ef688c175b.tar.bz2
rails-b7cce1c0a92ef88341137290eefd19ef688c175b.zip
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
Diffstat (limited to 'activerecord/lib/active_record/enum.rb')
-rw-r--r--activerecord/lib/active_record/enum.rb2
1 files changed, 1 insertions, 1 deletions
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