From d1ffe59ab5fd6e811833c127d43b32e87b5d7131 Mon Sep 17 00:00:00 2001 From: Akira Matsuda Date: Sat, 27 Jul 2019 12:56:39 +0900 Subject: Use match? where we don't need MatchData We're already running Performance/RegexpMatch cop, but it seems like the cop is not always =~ justice --- activerecord/lib/active_record/attribute_methods/query.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'activerecord/lib/active_record/attribute_methods') diff --git a/activerecord/lib/active_record/attribute_methods/query.rb b/activerecord/lib/active_record/attribute_methods/query.rb index 0cf67644af..5a21e36cc7 100644 --- a/activerecord/lib/active_record/attribute_methods/query.rb +++ b/activerecord/lib/active_record/attribute_methods/query.rb @@ -17,7 +17,7 @@ module ActiveRecord when false, nil then false else if !type_for_attribute(attr_name) { false } - if Numeric === value || value !~ /[^0-9]/ + if Numeric === value || !value.match?(/[^0-9]/) !value.to_i.zero? else return false if ActiveModel::Type::Boolean::FALSE_VALUES.include?(value) -- cgit v1.2.3