Sha256: af140f511671c7b24a50511c43bfcec11b0ca4f61db66db3e27f9e2b95bf9da3

Contents?: true

Size: 563 Bytes

Versions: 1

Compression:

Stored size: 563 Bytes

Contents

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

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
raddar-0.0.1.pre app/helpers/raddar/notifications_helper.rb