From 60f1a1e2d2c2a3caca30190c79e83f514840d0dd Mon Sep 17 00:00:00 2001 From: Zach Gollwitzer Date: Thu, 16 Jan 2025 16:24:14 -0500 Subject: [PATCH] Fix budget edit button --- app/models/budget.rb | 2 +- app/views/budgets/show.html.erb | 8 +++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/app/models/budget.rb b/app/models/budget.rb index 637ff50b..c5af34f7 100644 --- a/app/models/budget.rb +++ b/app/models/budget.rb @@ -139,7 +139,7 @@ class Budget < ApplicationRecord end def allocated_percent - return 0 unless budgeted_spending > 0 + return 0 unless budgeted_spending && budgeted_spending > 0 (allocated_spending / budgeted_spending.to_f) * 100 end diff --git a/app/views/budgets/show.html.erb b/app/views/budgets/show.html.erb index f9734976..0f63602b 100644 --- a/app/views/budgets/show.html.erb +++ b/app/views/budgets/show.html.erb @@ -53,9 +53,11 @@

Categories

- <%= link_to budget_budget_categories_path(@budget), class: "btn btn--secondary flex items-center gap-2" do %> - <%= icon "settings-2", color: "gray" %> - Edit + <% if @budget.initialized? %> + <%= link_to budget_budget_categories_path(@budget), class: "btn btn--secondary flex items-center gap-2" do %> + <%= icon "settings-2", color: "gray" %> + Edit + <% end %> <% end %>