Skip to content

Instantly share code, notes, and snippets.

@ErikDeBruijn
Created November 23, 2014 19:15
Show Gist options
  • Save ErikDeBruijn/33e80bb9f926b20eed79 to your computer and use it in GitHub Desktop.
Save ErikDeBruijn/33e80bb9f926b20eed79 to your computer and use it in GitHub Desktop.
#### A faster way to (interactively) delete some messages interactively on the rails console
#messages = Message.find(:all,:conditions => ["recipient_id = 3 and updated_at < ?", 20.days.ago])
messages = Message.find(:all,:conditions => ["recipient_id = 3"])
messages.each do |m|
input = ''
if m.content.include? "also commented on your comment" do
m.delete
next
end
puts "#{m.subject} #{m.created_at}"
puts "#{m.content}"
input = STDIN.gets.chomp
puts "Delete (y/N)? "
m.delete if input == 'y'
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment