Class: Admin::NotificationsController

Inherits:
ApplicationController
  • Object
show all
Defined in:
lib/generators/ruby_cms/templates/controllers/admin/notifications_controller.rb

Instance Method Summary collapse

Instance Method Details

#mark_all_readObject



15
16
17
18
19
20
# File 'lib/generators/ruby_cms/templates/controllers/admin/notifications_controller.rb', line 15

def mark_all_read
  user = current_user_cms
  user&.notifications&.unread&.mark_as_read
  bust_notifications_cache(user)
  redirect_back_or_to(admin_root_path)
end

#mark_readObject



5
6
7
8
9
10
11
12
13
# File 'lib/generators/ruby_cms/templates/controllers/admin/notifications_controller.rb', line 5

def mark_read
  user = current_user_cms
  notification = user&.notifications&.find_by(id: params[:id])
  notification&.mark_as_read

  bust_notifications_cache(user)
  redirect_target = safe_redirect_target(params[:next])
  redirect_to redirect_target
end