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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user