I have a ruby script that runs as a daemon process. After a new record is saved I want to delete all folders and files in the cache directory. I have tried the code below with no success:
require 'fileutils'
@report.save
FileUtils.rm_rf("absolute_path/tmp/cache/.")
# also tried
# FileUtils.rm_rf("#{RAILS.root}/tmp/cache/.")
FileUtils.rm_rfdoesn’t accept wildcards on its own. If you want want keep the cache directory itself, and remove its contents only, use aglob: