From 04da5dfc7e6fd867f9bfd1d053ec3688b9ece300 Mon Sep 17 00:00:00 2001 From: Bohung Date: Mon, 25 Oct 2021 11:03:51 +0800 Subject: [PATCH] Fix bug. --- app/models/ad_image.rb | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/app/models/ad_image.rb b/app/models/ad_image.rb index 911cf6e..4184073 100644 --- a/app/models/ad_image.rb +++ b/app/models/ad_image.rb @@ -73,9 +73,13 @@ class AdImage def youtube_thumb uri = URI.parse(self.youtube) rescue nil if !uri.nil? && uri.host == "www.youtube.com" - params = CGI.parse(uri.query) - v = params['v'].first - return "http://img.youtube.com/vi/#{v}/0.jpg" + params = CGI.parse(uri.query) rescue {} + if params.has_key?('v') + v = params['v'].first + return "http://img.youtube.com/vi/#{v}/0.jpg" + else + return "" + end else return "" end