Skip to content

A platform for community discussion. Free, open, simple.

FIX: reduce poll when post is nil

Régis Hanola188d15b08da
diff --git a/plugins/poll/plugin.rb b/plugins/poll/plugin.rb
index 4a494cf4c5b..c1fdd157f1e 100644
--- a/plugins/poll/plugin.rb
+++ b/plugins/poll/plugin.rb
@@ -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