I’m gathering data with the Facebook API and get_object requests with Koala are slow, so I’m trying to use delayed_job_active_record. However, I am having difficulty updating my model with the each do loop. @facebook is an array of IDs, and it works when I don’t use the .delay method, but doesn’t save when I use it.
How do I get this to work? I’m not sure where to put the .delay, or if I have to write it differently. Thanks for your help!
@facebook.each do |f|
Like.find_by_f_id(f).delay.name = @graph.get_object(f)["name"]
Like.find_by_f_id(f).delay.category = @graph.get_object(f)["category"]
Like.find_by_f_id(f).delay.save
end
Try this: