retrospring/app/controllers/notifications_controller.rb

19 lines
588 B
Ruby
Raw Normal View History

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