Skip to content

Commit

Permalink
Remove deprecated conditions parameter from #destroy_all
Browse files Browse the repository at this point in the history
  • Loading branch information
rafaelfranca committed Dec 29, 2016
1 parent 4fc3366 commit d31a6d1
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 16 deletions.
4 changes: 4 additions & 0 deletions activerecord/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
* Remove deprecated conditions parameter from `#destroy_all`.

*Rafael Mendonça França*

* Remove deprecated support to passing arguments to `#select` when a block is provided.

*Rafael Mendonça França*
Expand Down
12 changes: 2 additions & 10 deletions activerecord/lib/active_record/relation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -446,16 +446,8 @@ def update(id = :all, attributes)
# ==== Examples
#
# Person.where(age: 0..18).destroy_all
def destroy_all(conditions = nil)
if conditions
ActiveSupport::Deprecation.warn(<<-MESSAGE.squish)
Passing conditions to destroy_all is deprecated and will be removed in Rails 5.1.
To achieve the same use where(conditions).destroy_all.
MESSAGE
where(conditions).destroy_all
else
records.each(&:destroy).tap { reset }
end
def destroy_all
records.each(&:destroy).tap { reset }
end

# Destroy an object (or multiple objects) that has the given id. The object is instantiated first,
Expand Down
6 changes: 0 additions & 6 deletions activerecord/test/cases/relations_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1004,12 +1004,6 @@ def test_destroy_all
assert davids.loaded?
end

def test_destroy_all_with_conditions_is_deprecated
assert_deprecated do
assert_difference("Author.count", -1) { Author.destroy_all(name: "David") }
end
end

def test_delete_all
davids = Author.where(name: "David")

Expand Down

0 comments on commit d31a6d1

Please sign in to comment.