Class: LeanCms::NotificationsController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- ApplicationController
- LeanCms::NotificationsController
- Includes:
- Authorization
- Defined in:
- app/controllers/lean_cms/notifications_controller.rb
Instance Method Summary collapse
Instance Method Details
#index ⇒ Object
5 6 7 8 |
# File 'app/controllers/lean_cms/notifications_controller.rb', line 5 def index @notifications = current_user.notifications.order(created_at: :desc).page(params[:page]).per(20) @unread_count = current_user.notifications.unread.count end |
#mark_all_as_read ⇒ Object
21 22 23 24 |
# File 'app/controllers/lean_cms/notifications_controller.rb', line 21 def mark_all_as_read current_user.notifications.unread.update_all(read_at: Time.current) redirect_to lean_cms_notifications_path, notice: 'All notifications marked as read.' end |
#mark_as_read ⇒ Object
15 16 17 18 19 |
# File 'app/controllers/lean_cms/notifications_controller.rb', line 15 def mark_as_read @notification = current_user.notifications.find(params[:id]) @notification.mark_as_read! redirect_to lean_cms_notifications_path, notice: 'Notification marked as read.' end |
#show ⇒ Object
10 11 12 13 |
# File 'app/controllers/lean_cms/notifications_controller.rb', line 10 def show @notification = current_user.notifications.find(params[:id]) @notification.mark_as_read! unless @notification.read? end |