From 5cedcd309e1d49b059aa3011814ee32a7448e0d3 Mon Sep 17 00:00:00 2001 From: Aidan Cornelius-Bell Date: Sun, 15 Sep 2024 11:17:52 +0930 Subject: [PATCH] fixed an edge case where the rss would fail --- app/models/post.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) 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 -- 2.39.5