diff --git a/app/models/concerns/with_inheritance.rb b/app/models/concerns/with_inheritance.rb index 7f7dd625cd2ebe8d9f2f7e7500242fce0f72b047..e080daef0774cbc026b4e03368d58c1fc456b0bb 100644 --- a/app/models/concerns/with_inheritance.rb +++ b/app/models/concerns/with_inheritance.rb @@ -23,12 +23,14 @@ module WithInheritance def best(property) value = send(property) - value.blank? ? parent&.send("best_#{property}") : value + text = Static.html_to_text value.to_html + text.blank? ? parent&.send("best_#{property}") : value end def best_source(property, is_ancestor: false) value = send(property) - return (is_ancestor ? self : nil) if value.present? + text = Static.html_to_text value.to_html + return (is_ancestor ? self : nil) if text.present? parent&.send(:best_source, property, is_ancestor: true) end end diff --git a/app/services/static.rb b/app/services/static.rb index f74f72c2fca26feb70671fd54c06155833bad5f6..9e0ad12cf800cd1df232a1b136bfa83d97af2ecd 100644 --- a/app/services/static.rb +++ b/app/services/static.rb @@ -9,6 +9,12 @@ class Static string end + def self.html_to_text(string) + string = ActionController::Base.helpers.strip_tags string + string = string.strip + string + end + def self.render(template_static, about, website) code = ApplicationController.render( template: template_static,