From 9bd7a6fa13f0ee8f9c903e7a90c7770f88da4472 Mon Sep 17 00:00:00 2001 From: Alex Kotov Date: Wed, 10 Mar 2021 14:59:09 +0500 Subject: [PATCH] Improve method Profile#full_name --- app/models/profile.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/models/profile.rb b/app/models/profile.rb index 33d5cc7..e2c28c5 100644 --- a/app/models/profile.rb +++ b/app/models/profile.rb @@ -2,6 +2,7 @@ class Profile < ApplicationRecord has_many :posts def full_name - [first_name, last_name].map(&:presence).compact.join ' ' + [first_name, last_name].map(&:presence).compact.join(' ').presence || + "Profile#{" ##{id}" if id.present?}" end end