Try explicitly querying rather than getting postvisibilities

This commit is contained in:
Raphael Sofaer 2011-03-09 16:17:48 -08:00
parent 3f5844aaa0
commit eafa965504
2 changed files with 3 additions and 3 deletions

View file

@ -26,7 +26,7 @@ class ApplicationController < ActionController::Base
if user_signed_in? if user_signed_in?
@aspect = nil @aspect = nil
@object_aspect_ids = [] @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 @notification_count = Notification.for(current_user, :unread =>true).count
@unread_message_count = ConversationVisibility.sum(:unread, :conditions => "person_id = #{current_user.person.id}") @unread_message_count = ConversationVisibility.sum(:unread, :conditions => "person_id = #{current_user.person.id}")
@user_id = current_user.id @user_id = current_user.id

View file

@ -21,13 +21,13 @@ module ApplicationHelper
def aspects_with_post aspects, post def aspects_with_post aspects, post
aspects.select do |aspect| 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
end end
def aspects_without_post aspects, post def aspects_without_post aspects, post
aspects.reject do |aspect| 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
end end