From 2859975e81318203200b9bdec749dc763786ceff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juanjo=20Baza=CC=81n?= Date: Mon, 30 Jan 2017 11:51:19 +0100 Subject: [PATCH] adds scopes for final/voting_days officer_assignments --- app/models/poll/officer_assignment.rb | 3 +++ db/schema.rb | 7 ++++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/app/models/poll/officer_assignment.rb b/app/models/poll/officer_assignment.rb index 398149977..0eb68beb8 100644 --- a/app/models/poll/officer_assignment.rb +++ b/app/models/poll/officer_assignment.rb @@ -10,5 +10,8 @@ class Poll validates :date, presence: true, uniqueness: { scope: [:officer_id, :booth_assignment_id] } delegate :poll_id, :booth_id, to: :booth_assignment + + scope :voting_days, -> { where(final: false) } + scope :final, -> { where(final: true) } end end diff --git a/db/schema.rb b/db/schema.rb index 76360771d..8c437c012 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20170130101121) do +ActiveRecord::Schema.define(version: 20170130103550) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -413,9 +413,10 @@ ActiveRecord::Schema.define(version: 20170130101121) do create_table "poll_officer_assignments", force: :cascade do |t| t.integer "booth_assignment_id" t.integer "officer_id" - t.datetime "created_at", null: false - t.datetime "updated_at", null: false + t.datetime "created_at", null: false + t.datetime "updated_at", null: false t.datetime "date" + t.boolean "final", default: false end create_table "poll_officers", force: :cascade do |t|