Skip to content

fix(avatar): handle nil email with fallback to member-ID-based placeholder#2583

Merged
mroderick merged 1 commit intocodebar:masterfrom
mroderick:fix/gravatar-nil-email
Apr 22, 2026
Merged

fix(avatar): handle nil email with fallback to member-ID-based placeholder#2583
mroderick merged 1 commit intocodebar:masterfrom
mroderick:fix/gravatar-nil-email

Conversation

@mroderick
Copy link
Copy Markdown
Collaborator

@mroderick mroderick commented Apr 22, 2026

This was re-introduced when we null'ed invalid email addresses in the database in recent work fixing sending out email invites for workshops.

Summary

  • Fixes ActionView::Template::Error: undefined method 'strip' for nil when rendering avatar for members with nil email
  • Extracts MD5 hashing into new DigestHelper#md5_of helper (pure function)
  • Refactors Member#avatar to use fallback email (member-{id}@example.com) when member.email is nil
  • Removes deprecated Member#md5_email method

Error

Refs: https://app.rollbar.com/a/codebar-production/fix/item/codebar-production/676

ActionView::Template::Error: undefined method 'strip' for nil
Member#md5_email(/app/app/models/member.rb:176)
    Digest::MD5.hexdigest(email.strip.downcase)
Member#avatar(/app/app/models/member.rb:102)
    "https://secure.gravatar.com/avatar/#{md5_email}?size=#{size}&default=identicon"
image

Testing

  • Added tests for md5_of helper in spec/helpers/application_helper_spec.rb
  • Added test for nil email fallback in spec/models/member_spec.rb
  • All tests passing:
    • 41 member spec tests
    • 10 application helper spec tests

…older

Fixes ActionView::Template::Error: undefined method 'strip' for nil
when rendering avatar for members with nil email.

- Extract MD5 hashing into new DigestHelper md5_of method
- Refactor Member#avatar to use fallback email (member-{id}@example.com)
  when member.email is nil
- Remove deprecated md5_email method from Member
- Add tests for md5_of helper and nil email fallback in avatar

Refs: https://app.rollbar.com/a/codebar-production/fix/item/codebar-production/676
@mroderick mroderick merged commit 5e4ea93 into codebar:master Apr 22, 2026
8 checks passed
@mroderick mroderick deleted the fix/gravatar-nil-email branch April 22, 2026 09:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants