FIX: reduce poll when post is nil

This commit is contained in:
Régis Hanol 2019-05-30 00:02:33 +02:00 committed by GitHub
parent b24938b5ff
commit a188d15b08
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 1 deletions

View File

@ -437,8 +437,13 @@ after_initialize do
on(:reduce_excerpt) do |doc, options|
post = options[:post]
replacement = post ?
"<a href='#{UrlHelper.escape_uri(post.url)}'>#{I18n.t("poll.poll")}</a>" :
"#{I18n.t("poll.poll")}"
doc.css("div.poll").each do |poll|
poll.replace "<a href='#{UrlHelper.escape_uri(post.url)}'>#{I18n.t("poll.poll")}</a>"
poll.replace(replacement)
end
end