Retrospring/app/controllers/notifications_controller.rb

19 lines
588 B
Ruby
Raw Normal View History

2014-12-09 13:35:11 -08:00
class NotificationsController < ApplicationController
2014-12-12 08:54:13 -08:00
before_filter :authenticate_user!
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)
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