From b0a2072f961c6380e06ae14b8bbd5346cf6ed0e6 Mon Sep 17 00:00:00 2001 From: nilsding Date: Sun, 14 Dec 2014 15:24:59 +0100 Subject: [PATCH] made notification tabs work --- app/controllers/notifications_controller.rb | 5 +++++ app/views/notifications/_notification_tabs.html.haml | 10 +++++----- app/views/notifications/index.html.haml | 2 +- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/app/controllers/notifications_controller.rb b/app/controllers/notifications_controller.rb index a781df0d..5ad7c0c3 100644 --- a/app/controllers/notifications_controller.rb +++ b/app/controllers/notifications_controller.rb @@ -3,5 +3,10 @@ class NotificationsController < ApplicationController def index @type = params[:type] + @notifications = if @type == 'all' + Notification.for(current_user) + else + Notification.for(current_user).where('LOWER(target_type) = ?', @type) + end end end diff --git a/app/views/notifications/_notification_tabs.html.haml b/app/views/notifications/_notification_tabs.html.haml index e7efaa32..4bb01b43 100644 --- a/app/views/notifications/_notification_tabs.html.haml +++ b/app/views/notifications/_notification_tabs.html.haml @@ -2,8 +2,8 @@ .panel.panel-default .panel-body %ul.nav.nav-pills.nav-stacked - = nav_entry "All notifications", "" - = nav_entry "Answers", "" - = nav_entry "Smiles", "" - = nav_entry "Comments", "" - = nav_entry "Followers", "" \ No newline at end of file + = nav_entry "All notifications", notifications_path + = nav_entry "Answers", notifications_path('answer') + = nav_entry "Smiles", notifications_path('smile') + = nav_entry "Comments", notifications_path('comment') + = nav_entry "Followers", notifications_path('relationship') \ No newline at end of file diff --git a/app/views/notifications/index.html.haml b/app/views/notifications/index.html.haml index feebdd70..fe546235 100644 --- a/app/views/notifications/index.html.haml +++ b/app/views/notifications/index.html.haml @@ -2,7 +2,7 @@ = render 'notification_tabs' .col-md-9.col-xs-12.col-sm-9 %ul.list-group - - Notification.for(current_user).each do |notification| + - @notifications.each do |notification| %li.list-group-item .media - case notification.target_type