Class: Notifications::NotificationsController

Inherits:
ApplicationController show all
Defined in:
app/controllers/notifications/notifications_controller.rb

Instance Method Summary collapse

Methods inherited from ApplicationController

#authenticate_user!, #current_user

Instance Method Details

#cleanObject



15
16
17
18
# File 'app/controllers/notifications/notifications_controller.rb', line 15

def clean
  notifications.delete_all
  redirect_to notifications_path
end

#indexObject



3
4
5
6
7
8
9
10
11
12
13
# File 'app/controllers/notifications/notifications_controller.rb', line 3

def index
  @notifications = notifications.includes(:actor).order('id desc').page(params[:page])

  unread_ids = []
  @notifications.each do |n|
    unread_ids << n.id unless n.read?
  end
  Notification.read!(unread_ids)

  @notification_groups = @notifications.group_by { |note| note.created_at.to_date }
end