Created
November 23, 2014 19:15
-
-
Save ErikDeBruijn/33e80bb9f926b20eed79 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#### 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