#coding=utf-8 namespace :office do desc "conver any files to html" task :conver => :environment do all_count = Attachment.where(["container_type IN (?)", %w(Project Course)]).count i = 0 Attachment.where(["container_type IN (?)", %w(Project Course)]).find_each do |a| i += 1 puts "process [#{i}/#{all_count}] => id #{a.id}" saved_path = File.join(Rails.root, "files", "convered_office") unless Dir.exist?(saved_path) Dir.mkdir(saved_path) end convered_file = File.join(saved_path, a.disk_filename + ".pdf") office = Trustie::Utils::Office.new(a.diskfile) if office.conver(convered_file) puts "process ok: #{convered_file} " end end end end