From 641987874198574354501e1ad35dd8a153bf2cda Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juanjo=20Baza=CC=81n?= Date: Fri, 2 Dec 2016 14:24:31 +0100 Subject: [PATCH] fixes booth-poll relation --- app/models/poll.rb | 4 ++-- app/models/poll/booth.rb | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/app/models/poll.rb b/app/models/poll.rb index 13f926f1c..f5734b83e 100644 --- a/app/models/poll.rb +++ b/app/models/poll.rb @@ -1,6 +1,6 @@ class Poll < ActiveRecord::Base - has_many :booth_assigments - has_many :booths, through: :booth_assigments, class_name: "Poll::BoothAssignment" + has_many :booth_assignments, class_name: "Poll::BoothAssignment" + has_many :booths, through: :booth_assignments has_many :voters, through: :booths, class_name: "Poll::Voter" has_many :officers, through: :booths, class_name: "Poll::Officer" has_many :questions diff --git a/app/models/poll/booth.rb b/app/models/poll/booth.rb index e5589391b..3b71983fa 100644 --- a/app/models/poll/booth.rb +++ b/app/models/poll/booth.rb @@ -1,11 +1,11 @@ class Poll class Booth < ActiveRecord::Base - has_many :booth_assigments - has_many :polls, through: :booth_assigments + has_many :booth_assignments, class_name: "Poll::BoothAssignment" + has_many :polls, through: :booth_assignments has_many :voters has_many :officing_booths, dependent: :destroy has_many :officers, through: :officing_booths - validates :name, presence: true + validates :name, presence: true, uniqueness: true end end \ No newline at end of file