1
0
Fork 0

Add associations Profile#followed_profiles, #following_profiles

This commit is contained in:
Alex Kotov 2021-03-10 15:46:12 +05:00
parent 7c1ec6acf5
commit c3a9f837bb
1 changed files with 10 additions and 0 deletions

View File

@ -9,6 +9,16 @@ class Profile < ApplicationRecord
class_name: 'Followship',
foreign_key: :object_profile_id
has_many :followed_profiles,
class_name: 'Profile',
through: :outgoing_followships,
source: :object_profile
has_many :following_profiles,
class_name: 'Profile',
through: :incoming_followships,
source: :subject_profile
def full_name
[first_name, last_name].map(&:presence).compact.join(' ').presence ||
"Profile#{" ##{id}" if id.present?}"