#coding=utf-8 namespace :zip do desc "手工打包作品" task :pack => :environment do include ZipService include Redmine::I18n homework = Object.const_get(ENV['CLASS']).find ENV["ID"] file_count = 0 homework.student_works.map { |work| file_count += work.attachments.count} if file_count > 0 zipfile = zip_homework_common homework else zipfile = {:message => "no file"} end puts "out: #{zipfile}" end end