From 7c1ec6acf52627ac1eef2006f457f108c508ca43 Mon Sep 17 00:00:00 2001 From: Alex Kotov Date: Wed, 10 Mar 2021 15:41:07 +0500 Subject: [PATCH] Add associations Profile#outgoing_followships, #incoming_followships --- app/models/profile.rb | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/app/models/profile.rb b/app/models/profile.rb index e2c28c5..791810e 100644 --- a/app/models/profile.rb +++ b/app/models/profile.rb @@ -1,6 +1,14 @@ class Profile < ApplicationRecord has_many :posts + has_many :outgoing_followships, + class_name: 'Followship', + foreign_key: :subject_profile_id + + has_many :incoming_followships, + class_name: 'Followship', + foreign_key: :object_profile_id + def full_name [first_name, last_name].map(&:presence).compact.join(' ').presence || "Profile#{" ##{id}" if id.present?}"