Simplify managing investment votes

If I'm right, the `investment_votes` instance variable only exists to
avoid several database queries to get whether the current user has
supported each of the investments.

However, that doesn't make much sense when only one investment is shown.
In this case, the number of queries stays the same, and so we can
simplify the code by rendering the component with an optional parameter.
This commit is contained in:
Javi Martín
2021-06-13 02:55:09 +02:00
parent d5f4313f59
commit 5fab843184
11 changed files with 16 additions and 28 deletions

View File

@@ -37,12 +37,10 @@ class Management::Budgets::InvestmentsController < Management::BaseController
end
def show
load_investment_votes(@investment)
end
def vote
@investment.register_selection(managed_user)
load_investment_votes(@investment)
respond_to do |format|
format.html { redirect_to management_budget_investments_path(heading_id: @investment.heading.id) }
format.js