1
0
Fork 0

Add associations Profile#outgoing_followships, #incoming_followships

master
Alex Kotov 2 years ago
parent 15680d6172
commit 7c1ec6acf5
  1. 8
      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?}"