rake tast can't access rails.cache
- by mark
Hi
I want to call a rake task from a cron job that stores remote weather data in the rails cache. However, I must be doing something pretty wrong here because I cannot find any solution through countless fruitless searches.
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 get the error
Anonymous modules have no name to be referenced by
Which leads me to believe the rails cache isn't available. Outputting Rails.class from the rake file gives me Module but Rails.cache.class again returns the above error. Do I need to include something here? Am I just hopeless at internet? :)
Thanks in advance.