From 0776283aaea7a448566eb3590d7e22b2fa8970d4 Mon Sep 17 00:00:00 2001 From: Daniel Nitsikopoulos Date: Sun, 11 Jun 2023 13:16:26 +1000 Subject: [PATCH] Only show published trips --- app/repos/trip_repo.rb | 1 + lib/adamantium/persistence/relations/trips.rb | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/app/repos/trip_repo.rb b/app/repos/trip_repo.rb index 8729115..bdb6305 100644 --- a/app/repos/trip_repo.rb +++ b/app/repos/trip_repo.rb @@ -10,6 +10,7 @@ module Adamantium def list trips + .published .order(:start_date) .reverse .to_a diff --git a/lib/adamantium/persistence/relations/trips.rb b/lib/adamantium/persistence/relations/trips.rb index 8d79a76..17a31ee 100644 --- a/lib/adamantium/persistence/relations/trips.rb +++ b/lib/adamantium/persistence/relations/trips.rb @@ -12,6 +12,10 @@ module Adamantium end auto_struct(true) + + def published + where(self[:start_date] <= Time.now) + end end end end