Add associations between users via invitations
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
class Invitation < ApplicationRecord
|
||||
# Relations
|
||||
belongs_to :user
|
||||
belongs_to :invitee, class_name: "User", foreign_key: 'invited_user_id', optional: true
|
||||
|
||||
# Validations
|
||||
validates_presence_of :user
|
||||
|
||||
@@ -3,6 +3,10 @@ class User < ApplicationRecord
|
||||
|
||||
# Relations
|
||||
has_many :invitations, dependent: :destroy
|
||||
has_one :invitation, inverse_of: :invitee, foreign_key: 'invited_user_id'
|
||||
has_one :inviter, through: :invitation, source: :user
|
||||
has_many :invitees, through: :invitations
|
||||
|
||||
has_many :donations, dependent: :nullify
|
||||
|
||||
has_one :lndhub_user, class_name: "LndhubUser", inverse_of: "user",
|
||||
|
||||
Reference in New Issue
Block a user