removes answer <-> voter association
This commit is contained in:
@@ -3,8 +3,6 @@ class Poll::Answer < ActiveRecord::Base
|
||||
belongs_to :question, -> { with_hidden }
|
||||
belongs_to :author, -> { with_hidden }, class_name: 'User', foreign_key: 'author_id'
|
||||
|
||||
has_one :voter
|
||||
|
||||
delegate :poll, :poll_id, to: :question
|
||||
|
||||
validates :question, presence: true
|
||||
@@ -16,6 +14,6 @@ class Poll::Answer < ActiveRecord::Base
|
||||
scope :by_question, -> (question_id) { where(question_id: question_id) }
|
||||
|
||||
def record_voter_participation
|
||||
Poll::Voter.create_from_user(author, {poll_id: poll_id, answer_id: id})
|
||||
Poll::Voter.create_from_user(author, {poll_id: poll_id})
|
||||
end
|
||||
end
|
||||
@@ -2,7 +2,6 @@ class Poll
|
||||
class Voter < ActiveRecord::Base
|
||||
belongs_to :poll
|
||||
belongs_to :booth_assignment
|
||||
belongs_to :answer
|
||||
|
||||
validates :poll, presence: true
|
||||
validates :document_number, presence: true, uniqueness: { scope: [:poll_id, :document_type], message: :has_voted }
|
||||
@@ -26,7 +25,6 @@ class Poll
|
||||
def self.create_from_user(user, options = {})
|
||||
poll_id = options[:poll_id]
|
||||
booth_assignment_id = options[:booth_assignment_id]
|
||||
answer_id = options[:answer_id]
|
||||
|
||||
Voter.create(
|
||||
document_type: user.document_type,
|
||||
@@ -35,8 +33,7 @@ class Poll
|
||||
booth_assignment_id: booth_assignment_id,
|
||||
gender: user.gender,
|
||||
geozone_id: user.geozone_id,
|
||||
age: user.age,
|
||||
answer_id: answer_id
|
||||
age: user.age
|
||||
)
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user