diff options
author | Eileen M. Uchitelle <eileencodes@users.noreply.github.com> | 2017-10-18 08:21:36 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-10-18 08:21:36 -0400 |
commit | ded41a9b84299f536bc136d78069a50a2e867768 (patch) | |
tree | b2c5c25418b925bb49ac6f6604db4e9ef9195d22 | |
parent | d7ee4f2059ef6a51a5e9f7323cd669a2998301e0 (diff) | |
parent | 64b45b2fe1b9f64517f88c3b69c851d9c60ad77c (diff) | |
download | rails-ded41a9b84299f536bc136d78069a50a2e867768.tar.gz rails-ded41a9b84299f536bc136d78069a50a2e867768.tar.bz2 rails-ded41a9b84299f536bc136d78069a50a2e867768.zip |
Merge pull request #30914 from bogdanvlviv/active_record_basics-guides-add-destroy_all
Add mention how to delete several records in bulk to Active Record Basics Guides [ci skip]
-rw-r--r-- | guides/source/active_record_basics.md | 11 |
1 files changed, 11 insertions, 0 deletions
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 ----------- |