Rails Tip #03 - Deleting all the records

in #rails6 years ago

The task

Create a method that deletes all spam posts

in order to do this task, we need to have Post with a status of spam
then we can use symbol to proc with collect method to remove all the spam posts

Post.all.where(status: "spam").collect(&:destroy)
Sort:  

Hey man, a little context about these snippets would help a lot. Especially those who are seeing your posts for the first time.

Thanks
Nice post

Ops thanks for this story

Thanks for share,nice post.

Could you please explain how this works? Thanks

upvote, comment plz

hey @bilal-haider that's an amazing task. I am impressed by your programming skills. Definitely we will perform this task.
looking forward for more posts from you.

Thanks :) will keep posting.

nice post

You get a resteem from getupvote.
Follow me @getupvote and get a upvote and resteem thank u

Coin Marketplace

STEEM 0.23
TRX 0.12
JST 0.029
BTC 66857.85
ETH 3479.73
USDT 1.00
SBD 3.18