diff --git a/activerecord/lib/active_record/scoping/named.rb b/activerecord/lib/active_record/scoping/named.rb index 46cfb2ea2157a374bc59bd1370e94f10116cae96..d1bf4bdead3f69f313e4d32924b8b86a4528aafb 100644 --- a/activerecord/lib/active_record/scoping/named.rb +++ b/activerecord/lib/active_record/scoping/named.rb @@ -199,7 +199,7 @@ def scope(name, body, &block) private def singleton_method_added(name) - generate_relation_method(name) if Kernel.respond_to?(name) + generate_relation_method(name) if Kernel.respond_to?(name) && !ActiveRecord::Relation.method_defined?(name) end def valid_scope_name?(name) diff --git a/activerecord/test/models/reply.rb b/activerecord/test/models/reply.rb index 074a51f3df45857b6485e1faf88b138eeede9fb4..49536a02e1522dcee29a937a1cae8ae3fe160d74 100644 --- a/activerecord/test/models/reply.rb +++ b/activerecord/test/models/reply.rb @@ -10,9 +10,14 @@ class Reply < Topic scope :ordered, -> { Reply.order(:id) } + # Method on Kernel def self.open approved end + + # Methods both on Kernel and Relation + def self.load(data:); end + def self.select(data:); end end class SillyReply < Topic