ぼざクリタグ広場 https://hub.nizika.monster
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

14 lines
365 B

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