这是我最后的耙任务,以防万一它可以帮助任何人
require 'redis'task :cron => :environment do uri = URI.parse(REDIS_URL) REDIS = Redis.new(:host => uri.host, :port => uri.port, :password => uri.password) Pages.all.each do |p| views = REDIS.get(p.id.to_s) if views p.hits = p.hits + views.to_i if p.save REDIS.set pId, "0" end end end end



