2
我想从一个将远程天气数据存储在rails缓存中的cron作业调用rake任务。但是,我必须在这里做一些非常错误的事情,因为我无法通过无数次无果的搜索找到任何解决方案。rake任务无法访问rails.cache
说我定义和调用这个任务
namespace :weather do
desc "Store weather from remote source to cache"
task :cache do
Rails.cache.write('weather_data', Date.today)
end
end
我得到的错误
Anonymous modules have no name to be referenced by
这使我相信轨道缓存不可用。从rake文件输出Rails.class给了我Module,但Rails.cache.class再次返回上面的错误。我需要在这里包括什么吗?我只是在互联网上绝望吗? :)
在此先感谢。