Class: Api::NotificationsController

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

Instance Method Summary collapse

Instance Method Details

#indexObject



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

def index
  if params[:is_read]
    @notifications = current_user.notifications.where(is_read: params[:is_read] == "true")
  else
    @notifications = current_user.notifications
  end
end

#showObject



13
14
# File 'app/controllers/wupee/api/notifications_controller.rb', line 13

def show
end

#updateObject



16
17
18
19
# File 'app/controllers/wupee/api/notifications_controller.rb', line 16

def update
  @notification.mark_as_read
  render :show
end

#update_allObject



21
22
23
24
25
26
# File 'app/controllers/wupee/api/notifications_controller.rb', line 21

def update_all
  current_user.notifications.where(is_read: false).find_each do |n|
    n.mark_as_read
  end
  head :no_content
end