Class: Poll
Instance Method Summary
collapse
included, #set_guid
#object_to_receive, #subscribers
Instance Method Details
#as_json(options = {}) ⇒ Object
27
28
29
30
31
32
33
34
35
|
# File 'app/models/poll.rb', line 27
def as_json(options={})
{
poll_id: id,
post_id: status_message.id,
question: question,
poll_answers: poll_answers,
participation_count: participation_count
}
end
|
#enough_poll_answers ⇒ Object
23
24
25
|
# File 'app/models/poll.rb', line 23
def enough_poll_answers
errors.add(:poll_answers, I18n.t("activerecord.errors.models.poll.attributes.poll_answers.not_enough_poll_answers")) if poll_answers.size < 2
end
|
#participation_answer(user) ⇒ Object
37
38
39
|
# File 'app/models/poll.rb', line 37
def participation_answer(user)
poll_participations.find_by(author_id: user.person.id)
end
|
#participation_count ⇒ Object
41
42
43
|
# File 'app/models/poll.rb', line 41
def participation_count
poll_answers.sum("vote_count")
end
|