From 0fed4382159adfcb0e2b9d6fbff310e04da68c9a Mon Sep 17 00:00:00 2001 From: ChakibMoMi Date: Thu, 9 Apr 2026 00:09:27 +0200 Subject: [PATCH] fix: apply PR review fixes - accessibility labels and nil memoization --- app/models/retirement_config.rb | 3 ++- app/views/retirement/show.html.erb | 10 +++++----- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/app/models/retirement_config.rb b/app/models/retirement_config.rb index 97f4b3d0d..ca4de39bf 100644 --- a/app/models/retirement_config.rb +++ b/app/models/retirement_config.rb @@ -167,6 +167,7 @@ class RetirementConfig < ApplicationRecord private def latest_pension_entry - @latest_pension_entry ||= pension_entries.order(recorded_at: :desc).first + return @latest_pension_entry if defined?(@latest_pension_entry) + @latest_pension_entry = pension_entries.order(recorded_at: :desc).first end end diff --git a/app/views/retirement/show.html.erb b/app/views/retirement/show.html.erb index 5e08b0390..8020a2884 100644 --- a/app/views/retirement/show.html.erb +++ b/app/views/retirement/show.html.erb @@ -151,24 +151,24 @@ <%= form_with url: add_pension_entry_retirement_path, method: :post, scope: :pension_entry, class: "space-y-4" do |f| %>
- + <%= f.label :recorded_at, t(".date"), class: "block text-sm font-medium text-secondary mb-1" %> <%= f.date_field :recorded_at, value: Date.current, class: "form-input w-full rounded-lg border border-secondary bg-container text-sm text-primary px-3 py-2", required: true %>
- + <%= f.label :current_points, t(".pension_points"), class: "block text-sm font-medium text-secondary mb-1" %> <%= f.number_field :current_points, step: 0.0001, min: 0, class: "form-input w-full rounded-lg border border-secondary bg-container text-sm text-primary px-3 py-2", required: true %>
- + <%= f.label :current_monthly_pension, t(".current_pension"), class: "block text-sm font-medium text-secondary mb-1" %> <%= f.number_field :current_monthly_pension, step: 0.01, min: 0, class: "form-input w-full rounded-lg border border-secondary bg-container text-sm text-primary px-3 py-2" %>
- + <%= f.label :projected_monthly_pension, t(".projected_pension"), class: "block text-sm font-medium text-secondary mb-1" %> <%= f.number_field :projected_monthly_pension, step: 0.01, min: 0, class: "form-input w-full rounded-lg border border-secondary bg-container text-sm text-primary px-3 py-2" %>
- + <%= f.label :notes, t(".notes"), class: "block text-sm font-medium text-secondary mb-1" %> <%= f.text_field :notes, class: "form-input w-full rounded-lg border border-secondary bg-container text-sm text-primary px-3 py-2", placeholder: t(".notes_placeholder") %>