fix: Undefined method `name' for nil:NilClass (#8562)

This commit is contained in:
Sivin Varghese
2023-12-15 09:03:16 +05:30
committed by GitHub
parent 6c480098f7
commit fd1813949a

View File

@@ -7,7 +7,7 @@
<% end %>
</div>
<% 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') %>