Skip to content

Instantly share code, notes, and snippets.

@MittalPatel-BTC
Created May 6, 2019 10:56
Show Gist options
  • Save MittalPatel-BTC/1477b08e61890ed2b609852a44dd1014 to your computer and use it in GitHub Desktop.
Save MittalPatel-BTC/1477b08e61890ed2b609852a44dd1014 to your computer and use it in GitHub Desktop.
Rails 6 delete_by and destroy_by methods
# 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