Created
January 17, 2013 01:07
-
-
Save defsan/4552616 to your computer and use it in GitHub Desktop.
What is the best way? Notes:
employee is association
presence will return nil if blank?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
employee ? employee.full_name : 'None' | |
or this: | |
employee.try(:full_name).presence || 'None' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
employee.try(:full_name) || 'None'
present? is superfluous, since blank string should be handled by validations if it's an illegal value