From b0f1b6245ec4ec5a155ec1bb2bb05156062945eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javi=20Mart=C3=ADn?= Date: Fri, 21 Dec 2018 17:16:51 +0100 Subject: [PATCH] Simplify scope usage Rails automatically calls the `id` method inside scopes and the variable name makes more sense if it represents investments instead of the number of investments. --- app/controllers/valuation/budgets_controller.rb | 7 +++---- app/views/valuation/budgets/index.html.erb | 2 +- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/app/controllers/valuation/budgets_controller.rb b/app/controllers/valuation/budgets_controller.rb index 990fffdda..338cccec4 100644 --- a/app/controllers/valuation/budgets_controller.rb +++ b/app/controllers/valuation/budgets_controller.rb @@ -7,10 +7,9 @@ class Valuation::BudgetsController < Valuation::BaseController def index @budget = current_budget if @budget.present? - @investments_with_valuation_open = @budget.investments - .by_valuator(current_user.valuator.try(:id)) - .valuation_open - .count + @investments = @budget.investments + .by_valuator(current_user.valuator) + .valuation_open end end end diff --git a/app/views/valuation/budgets/index.html.erb b/app/views/valuation/budgets/index.html.erb index f1fd302b6..3abc1f3c7 100644 --- a/app/views/valuation/budgets/index.html.erb +++ b/app/views/valuation/budgets/index.html.erb @@ -18,7 +18,7 @@ <%= t("budgets.phase.#{@budget.phase}") %> - <%= @investments_with_valuation_open %> + <%= @investments.count %> <%= link_to t("valuation.budgets.index.evaluate"),