Rake task cannot access rails.cache
I want to call a rake task from a cron job that stores remote weather data in a cache panel. However, I must be doing something rather wrong here because I cannot find any solution through countless fruitless searches.
Let's say I define and call this task
namespace :weather do
desc "Store weather from remote source to cache"
task :cache do
Rails.cache.write('weather_data', Date.today)
end
end
I am getting the error
Anonymous modules have no name to be referenced by
This leads me to think that cache rails are not available. Rails.class output from rake file gives me a module, but Rails.cache.class returns the above error again. Do I need to include something here? Am I just hopeless on the internet? :)
Thanks in advance.
+2
a source to share