liam said over 3 years ago on Friend Requests From Scratch :
Hey David, sure thing.

User model: 
class User < ApplicationRecord
  # Include default devise modules. Others available are:
  # :confirmable, :lockable, :timeoutable, :trackable and :omniauthable
  devise :database_authenticatable, :registerable,
         :recoverable, :rememberable, :validatable
	has_many :developments, dependent: :destroy
	has_many :connections
	has_many :connections, dependent: :destroy
	has_many :contacts, -> { where connections: { status: :accepted }}, through: :connections
	has_many :requested_contacts, -> { where connections: {status: :requested}}, through: :connections, source: :contact
	has_many :pending_contacts, -> { where connections: { status: :pending }}, through: :connections, source: :contact	
        has_many :blocked_contacts, -> { where connections: { status: :blocked }}, through: :connections, source: :contact

and the Connection model:
class Connection < ApplicationRecord
  belongs_to :user
  belongs_to :contact, class_name: 'User'
  enum status: {pending: 0, requested: 1, accepted: 2, blocked: 3}
  # id: 1
  # contact: 2

  # user_id: 1, contact_id: 2, status: :requested
  # user_id: 2, contact_id: 1, status: :pending
end

I've tried double and triple-checking my code to make sure it's the same as yours but I can't quite figure it out!