Pinging issues

Subscribe to Pinging issues 9 posts, 2 voices

 
Avatar Shpigford 30 posts

So I have an After Transfer ping set to “example.com/ping/job”. The contents of that method is:

def job
    HeyWatch::Job.create(:video_id => params[:video_id], :format_id => 31)
    @video = Video.find_by_key(params[:videokey])
    @video.update_attribute('videoid', params[:video_id])
    render :nothing => true
  end

The parameters that are getting sent to it are:

Parameters: {"Filename"=>"testmovie.mov", "video_id"=>"283438", "action"=>"job", 
"Upload"=>"Submit Query", "controller"=>"ping", "videokey"=>"feb8a4f8590e6c67"}

But rails is throwing a “undefined method `update_attribute’ for nil:NilClass” on the update_attribute line.

Any ideas what the issue could be? Is there some oddity with Rails and POST requests? I’ve spent quite a bit of time trying to figure out why this isn’t working but am just at a loss about what to try now.

FYI, the HeyWatch::Job.create line does work correctly. And if I manually set the contents of find_by_key (ie. Video.find_by_key('feb8a4f8590e6c67')) it works as it should.

 
Avatar Bruno Celeste 374 posts

That’s weird. If Video.find_by_key(‘feb8a4f8590e6c67’) works and Video.find_by_key(params[:videokey]) not, there must be a problem with the parameter.

If you log the parameter videokey, does it work?

 
Avatar Shpigford 30 posts

Well…this is odd. If I add puts params[:videokey] before the find…it works.

def job
  puts params[:videokey]
  @video = Video.find_by_key(params[:videokey])
  @video.update_attribute('videoid', params[:video_id])
  HeyWatch::Job.create(:video_id => params[:video_id], :format_id => 31)
  render :nothing => true
end

Ever heard of that?

 
Avatar Shpigford 30 posts

Well…the puts only works some of the time. How can I log the parameter?

 
Avatar Bruno Celeste 374 posts

Use logger:

logger.info params[:videokey].inspect
 
Avatar Shpigford 30 posts

Logger outputs params[:videokey] as it should

 
Avatar Shpigford 30 posts

So…this is odd. Looking in my logs, it actually looks like /ping/job is getting called before my video form is submitted. I’m using SWFUpload to upload the image and then once it’s finished, it submits the form. That would explain it not being able to do the find_by_key…because Job is actually getting called before it’s stored in the database.

That being a possibility…can I somehow delay the Job ping by a few seconds?

 
Avatar Shpigford 30 posts

Okay. So I think I figured out how to handle the delay issue. So for now…problem solved. :)

 
Avatar Bruno Celeste 374 posts

great you solved the problem