Last active
August 29, 2015 14:03
-
-
Save dreamr/043946e7d8fd94324e4f to your computer and use it in GitHub Desktop.
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
class User < ActiveRecord::Base | |
def display_name | |
full_name || email_designator || "I haz no name nor email!" | |
end | |
def email_designator | |
return nil if email.blank? | |
@email_designator = email.split("@")[0] | |
end | |
def full_name | |
@full_name = "#{first_name} #{last_name}" | |
@full_name unless @full_name.blank? | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Much nicer solution.