Merging Passed Parameters
- by Josh Crowder
I have a two data arrays sent in from a form, one called transloaded and the other video which is the actual form for the model. I need to get [:video_encoded][:url] and save that to [:video][:flash_url]
This is the passed arguments or transloaded, when I try and access [:transload][:results][:video_encode] I get nil.
print params[:transload]
{
"assembly_id":"d59b4293b3d79d2ccd1948c02421c6a6",
"status":"success",
"uploads":{
"video":{
"name":"bbc_one.mp4",
"mime":"video/mp4",
"ext":"mp4",
"size":601104,
"meta":{
"width":720,
"height":404,
"video_fps":25,
"video_bitrate":null,
"video_format":"avc1",
"video_codec":"ffh264",
"audio_bitrate":"128k",
"audio_codec":"faad",
"duration":3.07,
"device_vendor":null,
"device_name":null,
"device_software":null,
"latitude":null,
"longitude":null
},
"url":"http://tmp.transloadit.com/"
}
},
"results":{
"video_encode":{
"name":"bbc_one.flv",
"mime":"video/x-flv",
"steps":["encode","export"],
"ext":"flv",
"size":388317,
"meta":{
"width":480,
"height":320,
"video_fps":25,
"video_bitrate":"512k",
"video_format":"FLV1",
"video_codec":"ffflv",
"audio_bitrate":"64k",
"audio_codec":"mp3",
"duration":3.11,
"device_vendor":null,
"device_name":null,
"device_software":null,
"latitude":null,
"longitude":null
},
"url":"http://s3.transloadit.com/b7deac9c96af6c745e914e25d0350baa/7a/2b09e822265ac2328789b40dcc02ae/bbc_one.flv"
},
"video_encode_iphone":{
"name":"bbc_one.qt",
"mime":"video/quicktime",
"steps":["encode_iphone","export"],
"ext":"qt",
"size":218236,
"meta":{
"width":480,
"height":320,
"video_fps":25,
"video_bitrate":null,
"video_format":"avc1",
"video_codec":"ffh264",
"audio_bitrate":"128k",
"audio_codec":"faad",
"duration":3.04,
"device_vendor":null,
"device_name":null,
"device_software":null,
"latitude":null,
"longitude":null
},
"url":"http://s3.transloadit.com/31/58bcc80d5345e52a42c9773125e8f0/bbc_one.qt"
}
}
}
Here is what I am trying to use
video_links = {
:flash_url => params[:transload][:results][:video_encode][:url],
:mp4_url => params[:transload][:results][:video_encode_iphone][:url]
}
params[:video].merge(video_links)