From 68fb295db5a1779c50dd24df2d72b1ae5982067b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javi=20Mart=C3=ADn?= Date: Thu, 10 Jan 2019 15:09:58 +0100 Subject: [PATCH] Use `if` blocks instead of two ternary operators Using a simple ternary operator is usually fine; however, code combining two ternary operator is a bit hard to follow. --- app/helpers/budget_investments_helper.rb | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/app/helpers/budget_investments_helper.rb b/app/helpers/budget_investments_helper.rb index ee5aad93c..3918c9b0d 100644 --- a/app/helpers/budget_investments_helper.rb +++ b/app/helpers/budget_investments_helper.rb @@ -16,8 +16,15 @@ module BudgetInvestmentsHelper end def set_sorting_icon(direction, sort_by) - icon = direction == "desc" ? "icon-arrow-top" : "icon-arrow-down" - icon = sort_by.to_s == params[:sort_by] ? icon : "" + if sort_by.to_s == params[:sort_by] + if direction == "desc" + "icon-arrow-top" + else + "icon-arrow-down" + end + else + "" + end end def set_direction(current_direction)