Skip to content

Commit

Permalink
Add scopes for invitation status: accepted, rejected, and pending
Browse files Browse the repository at this point in the history
  • Loading branch information
andrew committed Jan 24, 2025
1 parent a9fb4b5 commit c253ffa
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions app/models/invitation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ class Invitation < ApplicationRecord

before_validation :generate_token, on: :create

scope :accepted, -> { where.not(accepted_at: nil) }
scope :rejected, -> { where.not(rejected_at: nil) }
scope :pending, -> { where(accepted_at: nil, rejected_at: nil) }

def self.delete_expired
Invitation.all.find_each do |invitation|
invitation.delete_expense if invitation.expired?
Expand Down

0 comments on commit c253ffa

Please sign in to comment.