diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 4315d3818db71531e1c41087c72e1d7a87c64fe9..9654cb515c99980f03c813c5bfb9782f52cddf9f 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -16,7 +16,7 @@ class ApplicationController < ActionController::Base if user_signed_in? @aspect = nil @object_aspect_ids = [] - @all_aspects = current_user.aspects + @all_aspects = current_user.aspects.includes(:aspect_memberships) @aspects_dropdown_array = @all_aspects.collect{|x| [x.to_s, x.id]} @notification_count = Notification.for(current_user, :unread =>true).count end diff --git a/app/controllers/aspects_controller.rb b/app/controllers/aspects_controller.rb index 79d19fff69fbe77478c24b58e6bb5096cced6d27..b985c0cfaecacb2e11c0702019a82ec512db2093 100644 --- a/app/controllers/aspects_controller.rb +++ b/app/controllers/aspects_controller.rb @@ -11,9 +11,9 @@ class AspectsController < ApplicationController def index if params[:a_ids] - @aspects = current_user.aspects.where(:id => params[:a_ids]).includes(:contacts) + @aspects = current_user.aspects.where(:id => params[:a_ids]).includes(:contacts => {:person => :profile}) else - @aspects = current_user.aspects.includes(:contacts) + @aspects = current_user.aspects.includes(:contacts => {:person => :profile}) end # redirect to signup @@ -22,13 +22,12 @@ class AspectsController < ApplicationController else @aspect_ids = @aspects.map{|a| a.id} - post_ids = @aspects.map{|a| a.post_ids}.flatten! @posts = StatusMessage.joins(:aspects).where(:pending => false, - :aspects => {:id => @aspect_ids}).includes(:person, {:comments => :person}, :photos).select('DISTINCT `posts`.*').paginate( + :aspects => {:id => @aspect_ids}).includes({:person => :profile}, {:comments => {:person => :profile}}, :photos).select('DISTINCT `posts`.*').paginate( :page => params[:page], :per_page => 15, :order => 'created_at DESC') - @contacts = current_user.contacts.includes(:person).where(:pending => false) + @contacts = current_user.contacts.includes(:person => :profile).where(:pending => false) @aspect = :all unless params[:a_ids] @@ -70,13 +69,13 @@ class AspectsController < ApplicationController end def show - @aspect = current_user.aspects.where(:id => params[:id]).includes(:contacts => :person).first + @aspect = current_user.aspects.where(:id => params[:id]).first redirect_to aspects_path('a_ids[]' => @aspect.id) end def edit @aspect = current_user.aspects.where(:id => params[:id]).first - @contacts = current_user.contacts.includes(:person).where(:pending => false) + @contacts = current_user.contacts.includes(:person => :profile).where(:pending => false) unless @aspect render :file => "#{Rails.root}/public/404.html", :layout => false, :status => 404 else @@ -88,9 +87,9 @@ class AspectsController < ApplicationController def manage @aspect = :manage - @contacts = current_user.contacts.includes(:person).where(:pending => false) - @remote_requests = Request.where(:recipient_id => current_user.person.id).includes(:sender) - @aspects = @all_aspects.includes(:contacts => :person) + @contacts = current_user.contacts.includes(:person => :profile).where(:pending => false) + @remote_requests = Request.where(:recipient_id => current_user.person.id).includes(:sender => :profile) + @aspects = @all_aspects.includes(:contacts => {:person => :profile}) end def update