Files
btrc-hub/backend/app/models/theatre_watching_user.rb
2026-03-18 23:01:04 +09:00

14 lines
365 B
Ruby

class TheatreWatchingUser < ApplicationRecord
self.primary_key = :theatre_id, :user_id
belongs_to :theatre
belongs_to :user
scope :active, -> { where('expires_at >= ?', Time.current) }
scope :expired, -> { where('expires_at < ?', Time.current) }
def active? = expires_at >= Time.current
def refresh! = update!(expires_at: 30.seconds.from_now)
end