你能从 rakefile (scheduler.rake) 中调用一个类方法吗?
我正在使用 Heroku Scheduler 插件并编写了一个调用类方法的任务,但是当我运行“heroku run rake auto_start_games”时收到错误消息
Connecting to database specified by DATABASE_URL
rake aborted!
compared with non class/module
这是我的任务代码:
task :auto_start_games => :environment do
all_Active_Games = Game.where(:game_active => 1)
not_flag = all_Active_Games > 0
started_games = []
unless all_Active_Games.length == 0
all_Active_Games.each do |x|
if x.players >= 2
x.winning_structure = 1 if x.players < 3
Comments.gameStartComment(x.id)
Game.gameHasStartedPush(x)
x.game_initialized = 1
x.was_recently_initiated = 1
started_games << x.id
else
Game.addDaytoStartandEnd(x.id)
Comment.gamePostponedComment(x.id)
end
end
end
puts "started games #{started_games}"
end