Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix the case where username is nil, not whodunnit
I encounter the problem where paper_trails's whodunnit isn't displayed. It turned out that `username` method returns nil. `try` method returns nil when there's no method, so when user doesn't have `email` method, `@user_class.find(@version.whodunnit).try(:email)` returns nil. Then, try this out: `nil rescue nil || :foo` This returns nil, surprisingly. This means if user doesn't have email method, username is always nil. So my fix is like below: `(nil rescue nil) || :foo` This returns `:foo` as expected.
- Loading branch information