0
0
Fork 0

Add invite filter (#5862)

This commit is contained in:
Yamagishi Kazutoshi 2017-12-02 00:40:02 +09:00 committed by Eugen Rochko
parent eee3b32b77
commit 74320971e2
6 changed files with 59 additions and 2 deletions

View file

@ -17,6 +17,9 @@ class Invite < ApplicationRecord
belongs_to :user, required: true
has_many :users, inverse_of: :invite
scope :available, -> { where(expires_at: nil).or(where('expires_at >= ?', Time.now.utc)) }
scope :expired, -> { where.not(expires_at: nil).where('expires_at < ?', Time.now.utc) }
before_validation :set_code
attr_reader :expires_in