1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Delegate to Enumerable#find for CollectionProxy

Since `Relation` includes `Enumerable`, it is enough to use `super`
simply.
This commit is contained in:
Ryuta Kamizono 2017-08-13 18:17:21 +09:00
parent e3962308e7
commit d22ffa1625
2 changed files with 13 additions and 16 deletions

View file

@ -74,9 +74,6 @@ module ActiveRecord
end
def find(*args)
if block_given?
load_target.find(*args) { |*block_args| yield(*block_args) }
else
if options[:inverse_of] && loaded?
args_flatten = args.flatten
raise RecordNotFound, "Couldn't find #{scope.klass.name} without an ID" if args_flatten.blank?
@ -92,7 +89,6 @@ module ActiveRecord
scope.find(*args)
end
end
end
def build(attributes = {}, &block)
if attributes.is_a?(Array)

View file

@ -135,8 +135,9 @@ module ActiveRecord
# # #<Pet id: 2, name: "Spook", person_id: 1>,
# # #<Pet id: 3, name: "Choo-Choo", person_id: 1>
# # ]
def find(*args, &block)
@association.find(*args, &block)
def find(*args)
return super if block_given?
@association.find(*args)
end
##