Skip to content

Instantly share code, notes, and snippets.

@stevepolitodesign
Created March 15, 2022 09:25
Show Gist options
  • Save stevepolitodesign/1829d8940e6f98486470385815ef2f36 to your computer and use it in GitHub Desktop.
Save stevepolitodesign/1829d8940e6f98486470385815ef2f36 to your computer and use it in GitHub Desktop.
Rails destroy_by example

Before

Post.where("published_at < ?", 2.weeks.ago).destroy_all

After

Post.destroy_by("published_at < ?", 2.weeks.ago)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment