1
0
Fork 0

Add associations Profile#outgoing_followships, #incoming_followships

This commit is contained in:
Alex Kotov 2021-03-10 15:41:07 +05:00
parent 15680d6172
commit 7c1ec6acf5
1 changed files with 8 additions and 0 deletions

View File

@ -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?}"