diff options
author | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2014-05-19 08:39:45 -0300 |
---|---|---|
committer | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2014-05-19 08:39:45 -0300 |
commit | b52e6393d30dcfd95dc24cfe32e143f78b8e0a98 (patch) | |
tree | d559ba272dba8cbd9252c670377cd1d6b24b8672 | |
parent | 88ee30ad1d2ed418dea166c936e6f5fda4c011db (diff) | |
parent | 540262afd7f1ebc675756fdeaee1a86c9f840f3e (diff) | |
download | rails-b52e6393d30dcfd95dc24cfe32e143f78b8e0a98.tar.gz rails-b52e6393d30dcfd95dc24cfe32e143f78b8e0a98.tar.bz2 rails-b52e6393d30dcfd95dc24cfe32e143f78b8e0a98.zip |
Merge pull request #15168 from eileencodes/return-early-on-delete-and-destroy-methods
Return early on delete and destroy methods
-rw-r--r-- | activerecord/lib/active_record/associations/collection_association.rb | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/activerecord/lib/active_record/associations/collection_association.rb b/activerecord/lib/active_record/associations/collection_association.rb index caf4e612f9..c5f7bcae7d 100644 --- a/activerecord/lib/active_record/associations/collection_association.rb +++ b/activerecord/lib/active_record/associations/collection_association.rb @@ -244,6 +244,7 @@ module ActiveRecord # are actually removed from the database, that depends precisely on # +delete_records+. They are in any case removed from the collection. def delete(*records) + return if records.empty? _options = records.extract_options! dependent = _options[:dependent] || options[:dependent] @@ -257,6 +258,7 @@ module ActiveRecord # Note that this method removes records from the database ignoring the # +:dependent+ option. def destroy(*records) + return if records.empty? records = find(records) if records.any? { |record| record.kind_of?(Fixnum) || record.kind_of?(String) } delete_or_destroy(records, :destroy) end |