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



12
13
14
15
# File 'app/controllers/notifications/notifications_controller.rb', line 12

def clean
  notifications.delete_all
  redirect_to notifications_path
end

#indexObject



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

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

  unread_ids = @notifications.reject(&:read?).select(&:id)
  Notification.read!(unread_ids)

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