提交 1b773bca 编写于 作者: J John Hawthorn

Avoid confliting Kernel-named scopes on Relation

A previous change made singleton methods eagerly define their relation
methods if it shared a name with a method on Kernel. This caused issues
with a few methods which were both defined on Kernel and on
AcitveRecord::Relation.

This commit avoids defining the method if it exists on AR::Relation.
上级 0dc3f514
......@@ -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)
......
......@@ -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
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册