adds relations to officer/booth assignments

This commit is contained in:
Juanjo Bazán
2017-01-03 22:20:22 +01:00
parent 8d52224121
commit 2886d6d954
2 changed files with 2 additions and 0 deletions

View File

@@ -4,6 +4,7 @@ class Poll
belongs_to :poll belongs_to :poll
has_many :officer_assignments, class_name: "Poll::OfficerAssignment", dependent: :destroy has_many :officer_assignments, class_name: "Poll::OfficerAssignment", dependent: :destroy
has_many :recounts, class_name: "Poll::Recount", dependent: :destroy
has_many :officers, through: :officer_assignments has_many :officers, through: :officer_assignments
has_many :voters has_many :voters
end end

View File

@@ -2,6 +2,7 @@ class Poll
class OfficerAssignment < ActiveRecord::Base class OfficerAssignment < ActiveRecord::Base
belongs_to :officer belongs_to :officer
belongs_to :booth_assignment belongs_to :booth_assignment
has_one :recount
validates :officer_id, presence: true validates :officer_id, presence: true
validates :booth_assignment_id, presence: true validates :booth_assignment_id, presence: true