From 0b107a3606db1096aaeeae9ad610791edd2e0051 Mon Sep 17 00:00:00 2001 From: Alexander Chebotarov Date: Fri, 8 Nov 2024 17:39:43 +0200 Subject: [PATCH] Keep scope --- app/models/api_key.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/models/api_key.rb b/app/models/api_key.rb index bea63826a56..35b6aedcd9d 100644 --- a/app/models/api_key.rb +++ b/app/models/api_key.rb @@ -10,7 +10,9 @@ class ApiKey < ApplicationRecord validates :value, uniqueness: true validates :value, presence: true, on: :update - default_scope { where('expires_at IS NULL OR expires_at > ?', Time.current) } + default_scope { active } + + scope :active, -> { where('expires_at IS NULL OR expires_at > ?', Time.current) } private