Skip to main content
2 of 3
added 22 characters in body
mmln
  • 101
  • 3

instead of:

if first_name.blank? && last_name.blank?
  'Name: unknown'
else
  first_name + ' ' + last_name
end

one who prefers oneliners could do:

"#{first_name} #{last_name}".strip.empty? ? "Name: unknown" : "#{first_name} #{last_name}"

whats more:

it prefer to move these helper methods to a helper method or a decorator using https://github.com/drapergem/draper

mmln
  • 101
  • 3