Created
May 6, 2019 10:56
-
-
Save MittalPatel-BTC/1477b08e61890ed2b609852a44dd1014 to your computer and use it in GitHub Desktop.
Rails 6 delete_by and destroy_by methods
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Example to destroy all users matching the given condition using destroy_by | |
User.destroy_by(email: "[email protected]") | |
User.destroy_by(email: "[email protected]", rating: 4) | |
# Example to destroy all users matching the given condition using delete_by | |
User.delete_by(email: "[email protected]") | |
User.delete_by(email: "[email protected]", rating: 4) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment