From eafa965504396d8bc31a4827d173ca6041fd1532 Mon Sep 17 00:00:00 2001 From: Raphael Sofaer Date: Wed, 9 Mar 2011 16:17:48 -0800 Subject: [PATCH] Try explicitly querying rather than getting postvisibilities --- app/controllers/application_controller.rb | 2 +- app/helpers/application_helper.rb | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 64b9a6970..13cb51b4e 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -26,7 +26,7 @@ class ApplicationController < ActionController::Base if user_signed_in? @aspect = nil @object_aspect_ids = [] - @all_aspects = current_user.aspects.includes(:aspect_memberships, :post_visibilities) + @all_aspects = current_user.aspects.includes(:aspect_memberships) @notification_count = Notification.for(current_user, :unread =>true).count @unread_message_count = ConversationVisibility.sum(:unread, :conditions => "person_id = #{current_user.person.id}") @user_id = current_user.id diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index e3927d237..d90e571ad 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -21,13 +21,13 @@ module ApplicationHelper def aspects_with_post aspects, post aspects.select do |aspect| - aspect.post_visibilities.detect{|pv| pv.post_id == post.id} + PostVisibility.exists?(:aspect_id => aspect.id, :post_id => post.id) end end def aspects_without_post aspects, post aspects.reject do |aspect| - aspect.post_visibilities.detect{|pv| pv.post_id == post.id} + PostVisibility.exists?(:aspect_id => aspect.id, :post_id => post.id) end end