简单而且可能是愚蠢的问题。在哪里? / models中的简单生成模型不起作用,/ lib中的新类也不起作用......只是关于未定义方法的错误等。
schedule.rb
every '* * * * *' do
runner 'UpdateDaysAgo.test'
end
模型
class UpdateDaysAgo < ActiveRecord::Base
def test
UpdateDaysAgo.create(channel: "nil", title: "nil", game: "nil", avatar: "nil", created_at: Time.now, updated_at: Time.now)
end
end
错误
/usr/local/rvm/gems/ruby-2.2.1/gems/activerecord-4.2.1/lib/active_record/dynamic_matchers.rb:26:in `method_missing': private method `test' called for #<Class:0x00000004db7b40> (NoMethodError)
每当工作正常时,command
上的一些cron作业都很好。但我不知道models
和runner
:/
答案 0 :(得分:1)
您应该创建class method:
class UpdateDaysAgo < ActiveRecord::Base
def self.test
UpdateDaysAgo.create(channel: "nil", title: "nil", game: "nil", avatar: "nil", created_at: Time.now, updated_at: Time.now)
end
end