mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
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.
This commit is contained in:
parent
0dc3f5146d
commit
1b773bca5c
2 changed files with 6 additions and 1 deletions
|
@ -199,7 +199,7 @@ module ActiveRecord
|
|||
|
||||
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
|
||||
|
|
Loading…
Reference in a new issue