From fd1813949a967a8013fc15078af0755dca409e7d Mon Sep 17 00:00:00 2001 From: Sivin Varghese <64252451+iamsivin@users.noreply.github.com> Date: Fri, 15 Dec 2023 09:03:16 +0530 Subject: [PATCH] fix: Undefined method `name' for nil:NilClass (#8562) --- app/views/public/api/v1/portals/_authors.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/public/api/v1/portals/_authors.html.erb b/app/views/public/api/v1/portals/_authors.html.erb index 86a0dae89..18abf92b2 100644 --- a/app/views/public/api/v1/portals/_authors.html.erb +++ b/app/views/public/api/v1/portals/_authors.html.erb @@ -7,7 +7,7 @@ <% end %> - <% first_author = category.articles.published.order(position: :asc).map(&:author).uniq.first.name %> + <% first_author = category.articles.published.order(position: :asc).map(&:author).uniq.first&.name || '' %> <% author_text = author_count > 1 ? "#{author_count} #{I18n.t('public_portal.common.authors')}" : "#{author_count} #{I18n.t('public_portal.common.author')}" %> <% other_authors_count = author_count - 1 %> <% other_authors_text = other_authors_count > 1 ? I18n.t('public_portal.common.others') : I18n.t('public_portal.common.other') %>