I have my site configured so that it will automatically render different versions of a video in the background. It’s actually working really well. If the video is successful in the three different transcodes it will send a success email. However, if it generates an error, it will send a failure email. The issue that I’m having is that i’m trying to pass self through to the Action Mailer so that I can atleast give the name of the video that is successful or failed. However, it appears that self is null.
model
def video_success(format, opts)
VideoMailer.video_success(self).deliver
end
def video_rescue(format, opts)
VideoMailer.video_error(self).deliver
end
uploader
version :mp4 do
process :encode_video => [:mp4, callbacks: {rescue: :video_rescue} ]
def full_filename(for_file)
"#{File.basename(for_file, File.extname(for_file))}.mp4"
end
end
version :webm do
process :encode_video => [:webm, callbacks: { after_transcode: :video_success, rescue: :video_rescue }]
def full_filename(for_file)
"#{File.basename(for_file, File.extname(for_file))}.webm"
end
end
Any thoughts on how this can be accomplished? Also, it would be best that if there was an error, to return the error message that is generated.
Secondly, each User model has an email address. The user who uploads the video should receive the email address. However, I’m having issues using current_user within the model. I’m thinking that it also has something to do with the backgrounder since that information is not passed over to the background process.
I added a class method to the end of the background processor
process_in_background :video, ParanoidVideoIn the models directory, I created
paranoid_video.rband referenced the delivery of the mail. This way, the Carrierwave_Backgrounder is handling the success method instead of Carrierwave-Video.I ended up creating a new field in the database called
last_updated_byand use this to return which user is being called. Granted, this is an extra call to the database when the user is being pulled, but I find that this is sufficient for my purposes. The background processor statically returns consistent handlers so I was able to just split the lines and gsub to get the ID.to_iwill pull the first numerical value which is always the Video id in my case.