Sha256: 1c92abe6d4e4987a595f87a7835a85eea4200c62d2af07db685435bb992c6b17

Contents?: true

Size: 739 Bytes

Versions: 1

Compression:

Stored size: 739 Bytes

Contents

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

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
raddar-0.0.1.pre app/controllers/raddar/notifications_controller.rb