Pinging issues
|
|
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. |
|
|
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? |
|
|
Well…this is odd. If I add
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? |
|
|
Well…the puts only works some of the time. How can I log the parameter? |
|
|
Use logger:
|
|
|
Logger outputs params[:videokey] as it should |
|
|
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? |
|
|
Okay. So I think I figured out how to handle the delay issue. So for now…problem solved. :) |
|
|
great you solved the problem |