Proposal related polls won't appear in votes section

Proposal related polls won't be shown in the public votes section.
This commit is contained in:
Juan Salvador Pérez García
2018-07-03 07:52:08 +02:00
parent c8b2f13cfd
commit 7cdb0c8ebf
2 changed files with 2 additions and 1 deletions

View File

@@ -9,7 +9,7 @@ class PollsController < ApplicationController
::Poll::Answer # trigger autoload
def index
@polls = @polls.send(@current_filter).includes(:geozones).sort_for_list.page(params[:page])
@polls = @polls.public_polls.send(@current_filter).includes(:geozones).sort_for_list.page(params[:page])
end
def show

View File

@@ -27,6 +27,7 @@ class Poll < ActiveRecord::Base
accepts_nested_attributes_for :questions, reject_if: :all_blank, allow_destroy: true
scope :for, ->(element) { where(related: element) }
scope :public_polls, -> { where(related: nil) }
scope :current, -> { where('starts_at <= ? and ? <= ends_at', Date.current.beginning_of_day, Date.current.beginning_of_day) }
scope :incoming, -> { where('? < starts_at', Date.current.beginning_of_day) }
scope :expired, -> { where('ends_at < ?', Date.current.beginning_of_day) }