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:
parent
e3962308e7
commit
d22ffa1625
2 changed files with 13 additions and 16 deletions
|
@ -74,9 +74,6 @@ module ActiveRecord
|
||||||
end
|
end
|
||||||
|
|
||||||
def find(*args)
|
def find(*args)
|
||||||
if block_given?
|
|
||||||
load_target.find(*args) { |*block_args| yield(*block_args) }
|
|
||||||
else
|
|
||||||
if options[:inverse_of] && loaded?
|
if options[:inverse_of] && loaded?
|
||||||
args_flatten = args.flatten
|
args_flatten = args.flatten
|
||||||
raise RecordNotFound, "Couldn't find #{scope.klass.name} without an ID" if args_flatten.blank?
|
raise RecordNotFound, "Couldn't find #{scope.klass.name} without an ID" if args_flatten.blank?
|
||||||
|
@ -92,7 +89,6 @@ module ActiveRecord
|
||||||
scope.find(*args)
|
scope.find(*args)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
def build(attributes = {}, &block)
|
def build(attributes = {}, &block)
|
||||||
if attributes.is_a?(Array)
|
if attributes.is_a?(Array)
|
||||||
|
|
|
@ -135,8 +135,9 @@ module ActiveRecord
|
||||||
# # #<Pet id: 2, name: "Spook", person_id: 1>,
|
# # #<Pet id: 2, name: "Spook", person_id: 1>,
|
||||||
# # #<Pet id: 3, name: "Choo-Choo", person_id: 1>
|
# # #<Pet id: 3, name: "Choo-Choo", person_id: 1>
|
||||||
# # ]
|
# # ]
|
||||||
def find(*args, &block)
|
def find(*args)
|
||||||
@association.find(*args, &block)
|
return super if block_given?
|
||||||
|
@association.find(*args)
|
||||||
end
|
end
|
||||||
|
|
||||||
##
|
##
|
||||||
|
|
Loading…
Reference in a new issue