destroy notifications when marked as read
This commit is contained in:
@@ -1,9 +1,26 @@
|
||||
class NotificationsController < ApplicationController
|
||||
before_action :authenticate_user!
|
||||
load_and_authorize_resource class: "User"
|
||||
after_action :mark_as_read, only: :show
|
||||
skip_authorization_check
|
||||
|
||||
def index
|
||||
@notifications = current_user.notifications.recent.for_render
|
||||
@notifications = current_user.notifications.unread.recent.for_render
|
||||
end
|
||||
|
||||
def show
|
||||
@notification = current_user.notifications.find(params[:id])
|
||||
redirect_to url_for(@notification.notifiable.commentable)
|
||||
end
|
||||
|
||||
def mark_all_as_read
|
||||
current_user.notifications.each { |notification| notification.mark_as_read }
|
||||
redirect_to notifications_path
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def mark_as_read
|
||||
@notification.mark_as_read
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user