Merge pull request #39256 from jhawthorn/methods_on_kernel_and_relation

Avoid confliting Kernel-named scopes on Relation
This commit is contained in:
John Hawthorn 2020-05-12 12:03:34 -07:00 committed by GitHub
commit 243d891072
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 1 deletions

View File

@ -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)

View File

@ -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