Skip to main content
edited body
Source Link
janos
  • 111.7k
  • 15
  • 152
  • 391

insteadInstead of:

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

oneOne who prefers onelinersone-liners could do:

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

whats more:

it preferFurthermore, it's better to move these helper methodssuch code to a helper method or a decorator using https://github.com/drapergem/draper

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

Instead of:

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

One who prefers one-liners could do:

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

Furthermore, it's better to move such code to a helper method or a decorator using https://github.com/drapergem/draper

added 22 characters in body
Source Link
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

instead of:

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

one 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 or a decorator using https://github.com/drapergem/draper

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

Source Link
mmln
  • 101
  • 3

instead of:

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

one 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 or a decorator using https://github.com/drapergem/draper