From 64b45b2fe1b9f64517f88c3b69c851d9c60ad77c Mon Sep 17 00:00:00 2001 From: bogdanvlviv Date: Wed, 18 Oct 2017 15:03:06 +0300 Subject: Add mention how to delete several records in bulk to Active Record Basics Guides [ci skip] --- guides/source/active_record_basics.md | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'guides') diff --git a/guides/source/active_record_basics.md b/guides/source/active_record_basics.md index 11aefcb05f..069a624984 100644 --- a/guides/source/active_record_basics.md +++ b/guides/source/active_record_basics.md @@ -304,6 +304,17 @@ user = User.find_by(name: 'David') user.destroy ``` +If you'd like to delete several records in bulk, you may use `destroy_all` +method: + +```ruby +# find and delete all users named David +User.where(name: 'David').destroy_all + +# delete all users +User.destroy_all +``` + Validations ----------- -- cgit v1.2.3