diff options
author | Ryuta Kamizono <kamipo@gmail.com> | 2016-08-02 16:51:23 +0900 |
---|---|---|
committer | Ryuta Kamizono <kamipo@gmail.com> | 2016-08-02 16:53:06 +0900 |
commit | a76ebe5019cdb26808ff513b9952cf7fb012ec20 (patch) | |
tree | fe34ac6581866c11f9bb2112e6384cf70ac23929 /activerecord/lib/active_record | |
parent | c205e3fca333e7c24dd1e36d439f83cdaf074e44 (diff) | |
download | rails-a76ebe5019cdb26808ff513b9952cf7fb012ec20.tar.gz rails-a76ebe5019cdb26808ff513b9952cf7fb012ec20.tar.bz2 rails-a76ebe5019cdb26808ff513b9952cf7fb012ec20.zip |
Remove unnecessary `set_inverse_instance` in finder methods
Because `scope` (`target_scope`) is a `AssociationRelation`.
`AssociationRelation` handles `set_inverse_instance`.
https://github.com/rails/rails/blob/v5.0.0/activerecord/lib/active_record/association_relation.rb#L31-L33
Diffstat (limited to 'activerecord/lib/active_record')
-rw-r--r-- | activerecord/lib/active_record/associations/collection_association.rb | 8 |
1 files changed, 2 insertions, 6 deletions
diff --git a/activerecord/lib/active_record/associations/collection_association.rb b/activerecord/lib/active_record/associations/collection_association.rb index 0eaa0a4f36..fea9f5d7f3 100644 --- a/activerecord/lib/active_record/associations/collection_association.rb +++ b/activerecord/lib/active_record/associations/collection_association.rb @@ -152,9 +152,7 @@ module ActiveRecord if loaded? n ? target.take(n) : target.first else - scope.take(n).tap do |record| - set_inverse_instance record if record.is_a? ActiveRecord::Base - end + scope.take(n) end end @@ -656,9 +654,7 @@ module ActiveRecord args.shift if args.first.is_a?(Hash) && args.first.empty? collection = fetch_first_nth_or_last_using_find?(args) ? scope : load_target - collection.send(type, *args).tap do |record| - set_inverse_instance record if record.is_a? ActiveRecord::Base - end + collection.send(type, *args) end end end |