Skip to content
Browse files

pull notifications count out of view as it really flies in the face o…

…f MVC
  • Loading branch information...
1 parent 0c8d549 commit 21b69622ee386dc64aad5449538edf856c0bab25 @agrobbin committed Dec 16, 2012
Showing with 6 additions and 2 deletions.
  1. +6 −1 app/controllers/institutions_controller.rb
  2. +0 −1 app/views/layouts/institutions.html.haml
View
7 app/controllers/institutions_controller.rb
@@ -1,6 +1,6 @@
class InstitutionsController < ApplicationController
- helper_method :current_institution, :current_user, :signed_in?, :within_section?
+ helper_method :current_institution, :current_user, :signed_in?, :within_section?, :notifications_count
before_filter :check_if_institution_exists, :require_user
@@ -38,6 +38,11 @@ def signed_in?
current_user.present?
end
+ def notifications_count
+ return @notifications_count if defined?(@notifications_count)
+ @notifications_count = current_user.notifications.unread.count
+ end
+
def require_user
redirect_to new_session_path and return unless signed_in?
end
View
1 app/views/layouts/institutions.html.haml
@@ -25,7 +25,6 @@
= link_to '', edit_user_path, class: 'modal icon-cogs', title: 'Settings'
%span #{current_user.email_address}@#{current_institution.email_domain} (#{link_to 'Sign Out', session_path, method: :delete})
#notifications.right
- - notifications_count = current_user.notifications.unread.count
= link_to notifications_path, id: 'notification-count', class: "modal #{notifications_count > 0 ? 'new' : nil}", title: 'Notifications' do
%span= notifications_count
#navigation.left

0 comments on commit 21b6962

Please sign in to comment.
Something went wrong with that request. Please try again.