8cf7107445
#295 #295 #295 #295 #295 #295 #295 Co-authored-by: miteruzo <miteruzo@naver.com> Reviewed-on: #296
14 lines
365 B
Ruby
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
|