From 9e27027f56f406b4e6ac3668832e314c668c4c1f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javi=20Mart=C3=ADn?= Date: Fri, 8 Nov 2019 21:11:25 +0100 Subject: [PATCH] Remove duplicate scope The scopes `created_by_admin` and `public_polls` were very similar. I'm using `created_by_admin` because `Poll.public_polls` feels redundant, and the reason for that name is we should not name the scope `public` because `public` is a ruby access modifier. --- app/controllers/polls_controller.rb | 2 +- app/models/poll.rb | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/app/controllers/polls_controller.rb b/app/controllers/polls_controller.rb index 78b11d321..2e4e12045 100644 --- a/app/controllers/polls_controller.rb +++ b/app/controllers/polls_controller.rb @@ -13,7 +13,7 @@ class PollsController < ApplicationController def index @polls = Kaminari.paginate_array( - @polls.public_polls.not_budget.send(@current_filter).includes(:geozones).sort_for_list + @polls.created_by_admin.not_budget.send(@current_filter).includes(:geozones).sort_for_list ).page(params[:page]) end diff --git a/app/models/poll.rb b/app/models/poll.rb index 8b07b8aeb..bd577670b 100644 --- a/app/models/poll.rb +++ b/app/models/poll.rb @@ -40,7 +40,6 @@ class Poll < ApplicationRecord 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 :expired, -> { where("ends_at < ?", Date.current.beginning_of_day) } scope :recounting, -> { where(ends_at: (Date.current.beginning_of_day - RECOUNT_DURATION)..Date.current.beginning_of_day) }