From: Aidan Cornelius-Bell Date: Sun, 15 Sep 2024 01:47:52 +0000 (+0930) Subject: fixed an edge case where the rss would fail X-Git-Url: https://gitweb.mndrdr.org/?a=commitdiff_plain;h=5cedcd309e1d49b059aa3011814ee32a7448e0d3;p=arelpe.git fixed an edge case where the rss would fail --- diff --git a/app/models/post.rb b/app/models/post.rb index 64e613e..d39b61c 100644 --- a/app/models/post.rb +++ b/app/models/post.rb @@ -47,10 +47,10 @@ class Post < ApplicationRecord def generate_excerpt(max_length = 180) stripped_content = ActionController::Base.helpers.strip_tags(content) - excerpt = stripped_content.split('.').first || stripped_content[0...max_length] - excerpt.gsub!("Dear friends,", "") - excerpt.gsub!(/\s+/, ' ') - excerpt.strip + excerpt = stripped_content.split('.').first if stripped_content.present? || stripped_content[0...max_length] if stripped_content.present? + excerpt.gsub!("Dear friends,", "") if excerpt.present? + excerpt.gsub!(/\s+/, ' ') if excerpt.present? + excerpt.strip if excerpt.present? end private