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) }