Rake task to remove the image and audio files created by captcha

To add a rake task to the rails application which removes all the image and audio files created by captcha, create a file named remove_captcha_files.rake in the lib/tasks directory.
Add the following code to the lib/tasks/remove_captcha_files.rake file…

desc “Remove captcha images and audio files”
task :remove_captcha_files do
image_path = “#{RAILS_ROOT}/public/images/captcha/”
audio_path = “#{RAILS_ROOT}/public/captcha_audio/”
Dir.foreach(image_path){|file| File.delete(image_path+file) […] Continue reading