Add invite filter (#5862)
This commit is contained in:
parent
eee3b32b77
commit
74320971e2
6 changed files with 59 additions and 2 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue