create social preview for comment that is missing commentable (#5171) [deploy]

This commit is contained in:
Molly Struve 2019-12-19 10:14:37 -06:00 committed by Ben Halpern
parent 662a99ade3
commit 36aed0458e
2 changed files with 3 additions and 3 deletions

View file

@ -40,7 +40,7 @@ class SocialPreviewsController < ApplicationController
def comment
@comment = Comment.find(params[:id])
@tag_badges = Badge.where(id: Tag.where(name: @comment.commentable.decorate.cached_tag_list_array).pluck(:badge_id))
@tag_badges = Badge.where(id: Tag.where(name: @comment.commentable&.decorate&.cached_tag_list_array).pluck(:badge_id))
set_respond
end

View file

@ -113,10 +113,10 @@
<% elsif @comment.title.size < 50 %>
<% font_size = 8.3 %>
<% else %>
<% font_size = 15 - ((((@comment.title).size**0.92) + 85) / 16) %>
<% font_size = 15 - (((@comment.title.size**0.92) + 85) / 16) %>
<% end %>
<div class="title-area">
<h2>re: <%= @comment.commentable.title %></h2>
<h2>re: <%= @comment.commentable&.title %></h2>
<h1 style="font-size:<%= font_size %>vw;"><%= @comment.title %></h1>
</div>
<div class="preview-user">