From f6c938df2a8f0bfbbfb7cb450124e164079fc6f0 Mon Sep 17 00:00:00 2001 From: Manny Dinssa <44172848+Dinssa@users.noreply.github.com> Date: Wed, 17 Jul 2024 09:21:47 +0100 Subject: [PATCH] Change function to read more clearly --- app/models/scheme.rb | 4 ++-- app/views/schemes/_scheme_list.html.erb | 2 +- app/views/schemes/show.html.erb | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/models/scheme.rb b/app/models/scheme.rb index 07f4f8c9f..342327636 100644 --- a/app/models/scheme.rb +++ b/app/models/scheme.rb @@ -295,8 +295,8 @@ class Scheme < ApplicationRecord status == :active end - def all_locations_inactive? - active? && locations.all? { |location| !location.active? } + def has_active_locations? + active? && locations.active.exists? end def any_location_active_on_date?(date) diff --git a/app/views/schemes/_scheme_list.html.erb b/app/views/schemes/_scheme_list.html.erb index 2317b038b..bb80c6bc1 100644 --- a/app/views/schemes/_scheme_list.html.erb +++ b/app/views/schemes/_scheme_list.html.erb @@ -28,7 +28,7 @@ <% row.with_cell(text: scheme.locations.visible&.count) %> <% row.with_cell do %> <%= status_tag_from_resource(scheme) %> - <% if scheme.all_locations_inactive? %> + <% unless scheme.has_active_locations? %> <%= content_tag(:div, "No currently active locations", class: "app-!-colour-muted", style: "margin-top: 10px") %> <% end %> <% end %> diff --git a/app/views/schemes/show.html.erb b/app/views/schemes/show.html.erb index d8f31fd37..ab005e18d 100644 --- a/app/views/schemes/show.html.erb +++ b/app/views/schemes/show.html.erb @@ -26,7 +26,7 @@