From 2dec890b25e89d7f57034375315695cec59e0476 Mon Sep 17 00:00:00 2001 From: chiu Date: Wed, 25 Mar 2020 11:58:05 +0800 Subject: [PATCH] fix error --- app/controllers/faqs_controller.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/controllers/faqs_controller.rb b/app/controllers/faqs_controller.rb index 7cc5a11..895e39d 100644 --- a/app/controllers/faqs_controller.rb +++ b/app/controllers/faqs_controller.rb @@ -45,7 +45,9 @@ class FaqsController < ApplicationController tags = faq.tags.map{|tag| { "tag" => tag.name } } rescue [] temp_rich_title = Nokogiri::HTML(faq.rich_title).css('body') temp_rich_title.children.each_with_index do |child,i| - temp_rich_title.children[i].attribute('style').value = child.attribute('style').value.gsub(/\b(?:font-size\s*?:\s*([^;>]*?)(?=[;">}]))/,'') + if !child.attribute('style').nil? + temp_rich_title.children[i].attribute('style').value = child.attribute('style').value.gsub(/\b(?:font-size\s*?:\s*([^;>]*?)(?=[;">}]))/,'') + end end { "extras" => {"question" => temp_rich_title,"answer" => faq.answer},