Rails problem with Delayed_Job and Active Record
Posted
by Michael Waxman
on Stack Overflow
See other posts from Stack Overflow
or by Michael Waxman
Published on 2009-11-09T18:45:57Z
Indexed on
2010/05/28
9:41 UTC
Read the original article
Hit count: 241
ruby-on-rails
|delayed-job
I'm using Delayed_Job to grab a Twitter user's data from the API, but it's not saving it in the model for some reason! Please help! (code below)
class BandJob < Struct.new(:band_id, :band_username) #parameter
def perform
require 'json'
require 'open-uri'
band = Band.find_by_id(band_id)
t = JSON.parse(open("http://twitter.com/users/show/#{band_username}.json").read)
band.screen_name = t['screen_name']
band.profile_background_image = t['profile_background_image_url']
band.url = 'http://' + band_username + '.com'
band.save!
end
end
To clarify, I'm actually not getting any errors, it's just not saving. Here's what my log looks like:
* [JOB] acquiring lock on BandJob
[4;36;1mDelayed::Job Update (3.1ms)[0m [0;1mUPDATE "delayed_jobs" SET locked_at = '2009-11-09 18:59:45', locked_by = 'host:dhcp128036151228.central.yale.edu pid:2864' WHERE (id = 10442 and (locked_at is null or locked_at < '2009-11-09 14:59:45') and (run_at <= '2009-11-09 18:59:45')) [0m
[4;35;1mBand Load (1.5ms)[0m [0mSELECT * FROM "bands" WHERE ("bands"."id" = 34) LIMIT 1[0m
[4;36;1mBand Update (0.6ms)[0m [0;1mUPDATE "bands" SET "updated_at" = '2009-11-09 18:59:45', "profile_background_image" = 'http://a3.twimg.com/profile_background_images/38193417/fbtile4.jpg', "url" = 'http://Coldplay.com', "screen_name" = 'coldplay' WHERE "id" = 34[0m
[4;35;1mDelayed::Job Destroy (0.5ms)[0m [0mDELETE FROM "delayed_jobs" WHERE "id" = 10442[0m
* [JOB] BandJob completed after 0.5448
1 jobs processed at 1.8011 j/s, 0 failed ...
Thanks!
© Stack Overflow or respective owner