Fix NoMethodError in polls#voters

This commit is contained in:
Penar Musaraj 2018-10-09 12:51:49 -04:00
parent a0be127b6f
commit 753d39f30d
1 changed files with 1 additions and 0 deletions

View File

@ -245,6 +245,7 @@ after_initialize do
post = Post.find_by(id: post_id) post = Post.find_by(id: post_id)
raise Discourse::InvalidParameters.new("post_id is invalid") if !post raise Discourse::InvalidParameters.new("post_id is invalid") if !post
raise Discourse::InvalidParameters.new("no poll exists for this post_id") unless post.custom_fields[DiscoursePoll::POLLS_CUSTOM_FIELD]
poll = post.custom_fields[DiscoursePoll::POLLS_CUSTOM_FIELD][poll_name] poll = post.custom_fields[DiscoursePoll::POLLS_CUSTOM_FIELD][poll_name]
raise Discourse::InvalidParameters.new("poll_name is invalid") if !poll raise Discourse::InvalidParameters.new("poll_name is invalid") if !poll