Rails runner command not saving to cache

Posted by mark on Stack Overflow See other posts from Stack Overflow or by mark
Published on 2010-05-09T18:03:16Z Indexed on 2010/05/09 18:08 UTC
Read the original article Hit count: 262

Filed under:
|
|
|

Hi

I'm having a bit of a problem with a cron task generated by rails whenever plugin that should store remote data in the rails cache for display. What I have is this:

schedule.rb
set :path, '/var/www/apps/tuexplore/current'

every 1.hour do
  runner "Weather.cache_remote", :environment => :production
end

calls this model

class Weather
  def self.cache_remote
    Rails.cache.write('weather_data', Net::HTTP.get_response(URI.parse(WEATHER_URL)).body)
  end    
end

Calling whenever returns this

PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/home/deploy/.gem/ruby/1.8/bin

0 * * * * /var/www/apps/tuexplore/current/script/runner -e production "Weather.cache_remote"

This doesn't work. Calling the weather model method from a controller works fine, but I need to schedule it hourly. The cron task causes a "Cache write: weather_data" entry to appear in the production log but data isn't stored nor output into the page. Additional information, I can log into production console and run Weather.cache_remote, then read the data from the rails cache.

I'd be really appreciative if someone could point out the error of my ways. If further explanation is needed please ask. Thanks in advance for any pointers.

© Stack Overflow or respective owner

Related posts about ruby-on-rails

Related posts about whenever