From 0a3c86b92e9d483256ad6e7f08cf83e98c8318ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javi=20Mart=C3=ADn?= Date: Tue, 5 Apr 2022 22:44:30 +0200 Subject: [PATCH] Remove method to get votes for budget investments After commit 0214184b2, this method was only used in two places and was only useful in one of them. IMHO it isn't worth it add a monkey-patch for such a minor usage. --- app/models/user.rb | 4 ++-- config/initializers/vote_extensions.rb | 4 ---- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/app/models/user.rb b/app/models/user.rb index afb45baf5..290e47180 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -153,7 +153,7 @@ class User < ApplicationRecord end def voted_in_group?(group) - votes.for_budget_investments(Budget::Investment.where(group: group)).exists? + votes.where(votable: Budget::Investment.where(group: group)).exists? end def headings_voted_within_group(group) @@ -161,7 +161,7 @@ class User < ApplicationRecord end def voted_investments - Budget::Investment.where(id: votes.for_budget_investments.pluck(:votable_id)) + Budget::Investment.where(id: votes.where(votable: Budget::Investment.all).pluck(:votable_id)) end def administrator? diff --git a/config/initializers/vote_extensions.rb b/config/initializers/vote_extensions.rb index 8a7921a48..c7962b47a 100644 --- a/config/initializers/vote_extensions.rb +++ b/config/initializers/vote_extensions.rb @@ -13,10 +13,6 @@ ActsAsVotable::Vote.class_eval do Comment.public_for_api.pluck(:id)) end - def self.for_budget_investments(budget_investments = Budget::Investment.all) - where(votable_type: "Budget::Investment", votable_id: budget_investments) - end - def value vote_flag end