diff options
author | eileencodes <eileencodes@gmail.com> | 2014-04-23 22:35:23 -0400 |
---|---|---|
committer | eileencodes <eileencodes@gmail.com> | 2014-04-28 14:08:56 -0400 |
commit | e0e586094f968b1f8fa410aa84d105bc8e44e537 (patch) | |
tree | 2e229508d25e1e634a0f6721906ef59a3daa3a6d /activerecord | |
parent | 7ad476be6f5b843cded4d1d84d2d22f3f4b43dfc (diff) | |
download | rails-e0e586094f968b1f8fa410aa84d105bc8e44e537.tar.gz rails-e0e586094f968b1f8fa410aa84d105bc8e44e537.tar.bz2 rails-e0e586094f968b1f8fa410aa84d105bc8e44e537.zip |
simplify the delete all w/ dependency method
After reviewing this code I realized the conditional that was
there previously was basically saying if the dependency is not
delete all. This is a better, cleaner, and clearer way to write
this method.
Diffstat (limited to 'activerecord')
-rw-r--r-- | activerecord/lib/active_record/associations/collection_association.rb | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/activerecord/lib/active_record/associations/collection_association.rb b/activerecord/lib/active_record/associations/collection_association.rb index a0eba60101..9bf253d976 100644 --- a/activerecord/lib/active_record/associations/collection_association.rb +++ b/activerecord/lib/active_record/associations/collection_association.rb @@ -252,10 +252,10 @@ module ActiveRecord end def delete_all_with_dependency(dependent) - if (loaded? || dependent == :destroy) && dependent != :delete_all - delete_or_destroy(load_target, dependent) - else + if dependent == :delete_all delete_records(:all, dependent) + else + delete_or_destroy(load_target, dependent) end end |