2014-12-09 13:35:11 -08:00
|
|
|
class NotificationsController < ApplicationController
|
2020-04-18 16:45:50 -07:00
|
|
|
before_action :authenticate_user!
|
2014-12-12 08:54:13 -08:00
|
|
|
|
2014-12-09 13:35:11 -08:00
|
|
|
def index
|
2014-12-14 06:17:52 -08:00
|
|
|
@type = params[:type]
|
2014-12-14 06:24:59 -08:00
|
|
|
@notifications = if @type == 'all'
|
|
|
|
Notification.for(current_user)
|
2015-09-16 13:18:40 -07:00
|
|
|
elsif @type == 'new'
|
|
|
|
Notification.for(current_user).where(new: true)
|
2014-12-14 06:24:59 -08:00
|
|
|
else
|
|
|
|
Notification.for(current_user).where('LOWER(target_type) = ?', @type)
|
2015-01-08 09:22:27 -08:00
|
|
|
end.paginate(page: params[:page])
|
|
|
|
respond_to do |format|
|
|
|
|
format.html
|
|
|
|
format.js
|
|
|
|
end
|
2014-12-09 13:35:11 -08:00
|
|
|
end
|
|
|
|
end
|