diff options
author | Jenkins <jenkins@jenkins.ninjawedding.org> | 2017-12-02 14:17:11 +0000 |
---|---|---|
committer | Jenkins <jenkins@jenkins.ninjawedding.org> | 2017-12-02 14:17:11 +0000 |
commit | 933eafdcd3a3803e9fcf934f6f7ade667281c527 (patch) | |
tree | 94f5ab03f7cd733cc0743f3c79cf02a8de4c148f /app/models/invite.rb | |
parent | ad46bc9772dfc52c7ed522658eda1a3ef608a7b3 (diff) | |
parent | 51f2eca8877d8c56a19e1b8ce4edf407c2d236fb (diff) |
Merge remote-tracking branch 'tootsuite/master' into glitchsoc/master
Diffstat (limited to 'app/models/invite.rb')
-rw-r--r-- | app/models/invite.rb | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/app/models/invite.rb b/app/models/invite.rb index 7626f4cfa..6907c1f1d 100644 --- a/app/models/invite.rb +++ b/app/models/invite.rb @@ -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 |