FIX: Load user model when some attributes are missing.

Follow-up to 3ad07aacfa.
This commit is contained in:
Dan Ungureanu 2019-10-21 21:05:25 +03:00
parent ab53b485b4
commit 2f54dd5e3d
No known key found for this signature in database
GPG Key ID: 0AA2A00D6ACC8B84

View File

@ -218,8 +218,12 @@ class Notification < ActiveRecord::Base
def refresh_notification_count
begin
user.notifications.reset
user.publish_notifications_state
if user.has_attribute?(:seen_notification_id)
user.notifications.reset
user.publish_notifications_state
else
User.find_by(id: user.id).publish_notifications_state
end
rescue ActiveRecord::RecordNotFound
# happens when we delete a user
end