From 15f50635e7beaded8640f1e1646a27bb6c9a6fad Mon Sep 17 00:00:00 2001 From: Sivin Varghese <64252451+iamsivin@users.noreply.github.com> Date: Fri, 15 Dec 2023 09:41:35 +0530 Subject: [PATCH] fix: undefined method `available_name' for nil:NilClass (#8563) --- .../public/api/v1/portals/articles/_article_header.html.erb | 6 +++--- app/views/public/api/v1/portals/categories/show.html.erb | 4 +++- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/app/views/public/api/v1/portals/articles/_article_header.html.erb b/app/views/public/api/v1/portals/articles/_article_header.html.erb index f70d24519..4adc6a728 100644 --- a/app/views/public/api/v1/portals/articles/_article_header.html.erb +++ b/app/views/public/api/v1/portals/articles/_article_header.html.erb @@ -1,7 +1,7 @@ <% category_link_params = { portal_slug: @portal.slug, - category_locale: @article.category.locale, - category_slug: @article.category.slug, + category_locale: @article.category&.locale, + category_slug: @article.category&.slug, theme: @theme_from_params, is_plain_layout_enabled: @is_plain_layout_enabled } @@ -33,6 +33,6 @@
<%= render "public/api/v1/portals/thumbnail", author: article.author, size: 5 %>
- By <%= article.author.available_name %> • <%= I18n.t('public_portal.common.last_updated_on', last_updated_on: article.updated_at.strftime("%b %d, %Y")) %> + <%= "#{I18n.t('public_portal.common.by')} #{article.author&.available_name || article.author&.name || ''}" %> • <%= I18n.t('public_portal.common.last_updated_on', last_updated_on: article.updated_at.strftime("%b %d, %Y")) %> diff --git a/app/views/public/api/v1/portals/categories/show.html.erb b/app/views/public/api/v1/portals/categories/show.html.erb index 3e6398c0b..9ce4a7650 100644 --- a/app/views/public/api/v1/portals/categories/show.html.erb +++ b/app/views/public/api/v1/portals/categories/show.html.erb @@ -36,7 +36,9 @@
<% author = article.author %> <%= render "public/api/v1/portals/thumbnail", author: author, size: 5 %> - <%= "#{I18n.t('public_portal.common.by')} #{author.name}" %> + <% if author&.name.present? %> + <%= "#{I18n.t('public_portal.common.by')} #{author&.name}" %> + <% end %>
<%= I18n.t('public_portal.common.last_updated_on', last_updated_on: article.updated_at.strftime("%b %d, %Y")) %>