From a0a0a927819d9a2e9c7d5060f31cefeb14cc8047 Mon Sep 17 00:00:00 2001 From: Harry Bomrah Date: Wed, 5 Jul 2017 12:04:20 +0800 Subject: [PATCH] image issue solved --- app/controllers/hps_learnings_controller.rb | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/app/controllers/hps_learnings_controller.rb b/app/controllers/hps_learnings_controller.rb index 50caeac..2e583e5 100644 --- a/app/controllers/hps_learnings_controller.rb +++ b/app/controllers/hps_learnings_controller.rb @@ -4,8 +4,9 @@ class HpsLearningsController < ApplicationController classes = [] HpsClass.all.desc(:created_at).each do |hpsclass| if hpsclass.hps_lectures.count > 0 + thumb = hpsclass.course_pic.thumb.url.nil? ? "http://www.placehold.it/150x150/EFEFEF/AAAAAA" : hpsclass.course_pic.thumb.url classes << { - "course_pic_thumb" => (hpsclass.course_pic.thumb.url rescue "http://www.placehold.it/150x150/EFEFEF/AAAAAA"), + "course_pic_thumb" => thumb, "course_pic" => (hpsclass.course_pic.url rescue ""), "title" => hpsclass.title, "category" => hpsclass.category.title, @@ -29,8 +30,10 @@ class HpsLearningsController < ApplicationController lectures = [] hpsclass.hps_lectures.each do |lecture| if !lecture.hps_lecture_file.nil? && !lecture.hps_lecture_file.index_path.nil? + + thumb = lecture.lecture_pic.thumb.url.nil? ? "http://www.placehold.it/150x150/EFEFEF/AAAAAA" : lecture.lecture_pic.thumb.url lectures << { - "lecture_pic_thumb" => (lecture.lecture_pic.thumb.url rescue "http://www.placehold.it/150x150/EFEFEF/AAAAAA"), + "lecture_pic_thumb" => thumb, "lecture_pic" => (lecture.lecture_pic.url rescue ""), "subject" => lecture.subject, "presenter" => lecture.presenter,