Class: PollParticipation

Inherits:
ApplicationRecord show all
Includes:
Diaspora::Federated::Base, Diaspora::Fields::Author, Diaspora::Fields::Guid, Diaspora::Relayable
Defined in:
app/models/poll_participation.rb

Defined Under Namespace

Classes: Generator

Instance Method Summary collapse

Methods included from Diaspora::Relayable

#author_is_not_ignored, included, #parent, #root, #sender_for_dispatch, #subscribers

Methods included from Diaspora::Fields::Author

included

Methods included from Diaspora::Fields::Guid

included, #set_guid

Methods included from Diaspora::Federated::Base

#object_to_receive, #subscribers

Instance Method Details

#not_already_participatedObject


23
24
25
26
27
28
29
30
# File 'app/models/poll_participation.rb', line 23

def not_already_participated
  return if poll.nil?

  other_participations = PollParticipation.where(author_id: self.author.id, poll_id: self.poll.id).to_a-[self]
  if other_participations.present?
    self.errors.add(:poll, I18n.t("activerecord.errors.models.poll_participation.attributes.poll.already_participated"))
  end
end

#poll_answer_guid=(new_poll_answer_guid) ⇒ Object


19
20
21
# File 'app/models/poll_participation.rb', line 19

def poll_answer_guid=(new_poll_answer_guid)
  self.poll_answer_id = PollAnswer.where(guid: new_poll_answer_guid).ids.first
end