diff options
author | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2013-09-25 16:29:37 -0700 |
---|---|---|
committer | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2013-09-25 16:29:37 -0700 |
commit | 49d94cc4d921e43010eb992de66bea68b612bf97 (patch) | |
tree | 14d7bde184fe219416d243f3ac1a7296bb49c693 /activerecord/lib | |
parent | d1e36842ba8f3eb723fd65535cf292c898c73b68 (diff) | |
parent | dfd3b8096e31ec6bb288dc0041a2d716566649ee (diff) | |
download | rails-49d94cc4d921e43010eb992de66bea68b612bf97.tar.gz rails-49d94cc4d921e43010eb992de66bea68b612bf97.tar.bz2 rails-49d94cc4d921e43010eb992de66bea68b612bf97.zip |
Merge pull request #12362 from arthurnn/inverse_on_find
fix .find when inverse is loaded
Diffstat (limited to 'activerecord/lib')
-rw-r--r-- | activerecord/lib/active_record/associations/collection_association.rb | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/activerecord/lib/active_record/associations/collection_association.rb b/activerecord/lib/active_record/associations/collection_association.rb index 98d573a3a2..b9199f62b9 100644 --- a/activerecord/lib/active_record/associations/collection_association.rb +++ b/activerecord/lib/active_record/associations/collection_association.rb @@ -80,14 +80,13 @@ module ActiveRecord load_target.find(*args) { |*block_args| yield(*block_args) } else if options[:inverse_of] && loaded? - args = args.flatten - raise RecordNotFound, "Couldn't find #{scope.klass.name} without an ID" if args.blank? - + args_flatten = args.flatten + raise RecordNotFound, "Couldn't find #{scope.klass.name} without an ID" if args_flatten.blank? result = find_by_scan(*args) result_size = Array(result).size - if !result || result_size != args.size - scope.raise_record_not_found_exception!(args, result_size, args.size) + if !result || result_size != args_flatten.size + scope.raise_record_not_found_exception!(args_flatten, result_size, args_flatten.size) else result end |