module Raddar module NotificationsHelper def unread_notifications_count(user) user.notifications.where(unread: true).count end def last_notifications(user) user.notifications.order('created_at DESC').limit(10) end def link_to_notification(notification) text = t(notification.token, scope: 'notifications.tokens', notifiable: notification.notifiable.name) unread_class = notification.unread ? 'unread' : 'read' link_to(text, [raddar, notification], class: "notification #{ unread_class }") end end end