module Raddar class NotificationsController < Raddar::ApplicationController # GET /notifications # GET /notifications.json def index authorize(Notification.new) @notifications = current_user.notifications.order('created_at DESC').page(params[:page]) end # GET /notifications/1 # GET /notifications/1.json def show @notification = Notification.find(params[:id]) authorize(@notification) @notification.update_attribute(:unread, false) redirect_to @notification.item_path.presence || @notification.notifiable end def read_all authorize(Notification.new) current_user.notifications.update_all(unread: false) head :no_content end end end