From 10283c32ee65a314bf04a7a13569a3e62ad24430 Mon Sep 17 00:00:00 2001 From: kikito Date: Sat, 11 Feb 2017 11:14:15 +0100 Subject: [PATCH] Adds scopes to officer_assignment --- app/models/poll/officer_assignment.rb | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app/models/poll/officer_assignment.rb b/app/models/poll/officer_assignment.rb index bdd074995..7d0e31ded 100644 --- a/app/models/poll/officer_assignment.rb +++ b/app/models/poll/officer_assignment.rb @@ -17,6 +17,9 @@ class Poll scope :by_officer_and_poll, ->(officer_id, poll_id) do where("officer_id = ? AND poll_booth_assignments.poll_id = ?", officer_id, poll_id) end + scope :by_officer, ->(officer){ where(officer_id: officer.id) } + scope :by_poll, ->(poll){ joins(:booth_assignment).where("poll_booth_assignments.poll_id" => poll.id) } + scope :by_date, ->(date){ where(date: date) } before_create :log_user_data