Add associations Profile#outgoing_followships, #incoming_followships
This commit is contained in:
parent
15680d6172
commit
7c1ec6acf5
|
@ -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?}"
|
||||
|
|
Reference in New Issue