2017-01-09 16:22:58 +01:00
|
|
|
class NotificationsController < ApplicationController
|
2018-06-20 18:02:33 +02:00
|
|
|
load_and_authorize_resource :user, only: :index, find_by: :name
|
2017-01-09 16:22:58 +01:00
|
|
|
|
|
|
|
before_action :load_notification, only: :read
|
|
|
|
authorize_resource :notification, only: :read
|
|
|
|
|
|
|
|
def index
|
|
|
|
@notifications = @user.notifications.group_by(&:read)
|
|
|
|
end
|
|
|
|
|
|
|
|
def read
|
|
|
|
@notification.read!
|
2017-01-14 16:22:44 +01:00
|
|
|
redirect_to root_path
|
2017-01-09 16:22:58 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def load_notification
|
|
|
|
@notification = Notification.find params[:notification_id]
|
|
|
|
end
|
|
|
|
end
|