Last active
May 6, 2019 10:55
-
-
Save MittalPatel-BTC/94fe93c075550b2b4bcd635a215e279a to your computer and use it in GitHub Desktop.
Rails 5 destroy and delete feature
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 | |
User.find_by(email: "[email protected]").destroy | |
User.where(email: "[email protected]", rating: 4).destroy_all | |
# Example to delete all users matching the given condition | |
User.find_by(email: "[email protected]").delete | |
User.where(email: "[email protected]", rating: 4).delete_all |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment