Skip to content

Instantly share code, notes, and snippets.

@MittalPatel-BTC
Last active May 6, 2019 10:55
Show Gist options
  • Save MittalPatel-BTC/94fe93c075550b2b4bcd635a215e279a to your computer and use it in GitHub Desktop.
Save MittalPatel-BTC/94fe93c075550b2b4bcd635a215e279a to your computer and use it in GitHub Desktop.
Rails 5 destroy and delete feature
# 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