From 7cdb0c8ebf2a3511bc439359eaca482801d817c3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juan=20Salvador=20P=C3=A9rez=20Garc=C3=ADa?= Date: Tue, 3 Jul 2018 07:52:08 +0200 Subject: [PATCH] Proposal related polls won't appear in votes section Proposal related polls won't be shown in the public votes section. --- app/controllers/polls_controller.rb | 2 +- app/models/poll.rb | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/app/controllers/polls_controller.rb b/app/controllers/polls_controller.rb index 708f68abb..26379f8cb 100644 --- a/app/controllers/polls_controller.rb +++ b/app/controllers/polls_controller.rb @@ -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 diff --git a/app/models/poll.rb b/app/models/poll.rb index c15c67cc2..74400a9fe 100644 --- a/app/models/poll.rb +++ b/app/models/poll.rb @@ -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) }