Created
August 14, 2020 17:37
-
-
Save walshyb/6717e5cb8be5e88aac0a0e4814874169 to your computer and use it in GitHub Desktop.
Helper method to get primary email in User model
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
# app/models/user.rb | |
def email | |
email_address = email_addresses.where(primary: true).first | |
return email_address.email if email_address | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment