tab/app/controllers/notifications_controller.rb

22 lines
457 B
Ruby
Raw Normal View History

2017-01-09 15:22:58 +00:00
class NotificationsController < ApplicationController
2019-03-24 21:31:03 +00:00
load_and_authorize_resource :user, find_by: :name
2017-01-09 15:22:58 +00: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 15:22:44 +00:00
redirect_to root_path
2017-01-09 15:22:58 +00:00
end
private
def load_notification
@notification = Notification.find params[:notification_id]
end
end