Class: NotifyUser::NotificationsController

Inherits:
ApplicationController
  • Object
show all
Defined in:
app/controllers/notify_user/notifications_controller.rb

Instance Method Summary collapse

Instance Method Details

#indexObject



5
6
7
8
9
10
11
12
# File 'app/controllers/notify_user/notifications_controller.rb', line 5

def index
  @notifications = NotifyUser::BaseNotification.for_target(@user)
                                                .order("created_at DESC")
                                                .limit(30)
                                                .page(params[:page])

  render json: @notifications
end

#mark_readObject



14
15
16
17
18
# File 'app/controllers/notify_user/notifications_controller.rb', line 14

def mark_read
  @notifications = NotifyUser::BaseNotification.for_target(@user).where('id IN (?)', params[:ids])
  @notifications.update_all(state: :read)
  render json: @notifications
end