diff --git a/app/controllers/aspects_controller.rb b/app/controllers/aspects_controller.rb index f1949bee3..cc5afedcc 100644 --- a/app/controllers/aspects_controller.rb +++ b/app/controllers/aspects_controller.rb @@ -112,12 +112,12 @@ class AspectsController < ApplicationController def edit @aspect = current_user.aspects.where(:id => params[:id]).includes(:contacts => {:person => :profile}).first - @contacts_in_aspect = @aspect.contacts.includes(:person => :profile).all.sort! { |x, y| x.person.name <=> y.person.name } + @contacts_in_aspect = @aspect.contacts.includes(:aspect_memberships, :person => :profile).all.sort! { |x, y| x.person.name <=> y.person.name } c = Contact.arel_table if @contacts_in_aspect.empty? - @contacts_not_in_aspect = current_user.contacts.receiving.includes(:person => :profile).all.sort! { |x, y| x.person.name <=> y.person.name } + @contacts_not_in_aspect = current_user.contacts.receiving.includes(:aspect_memberships, :person => :profile).all.sort! { |x, y| x.person.name <=> y.person.name } else - @contacts_not_in_aspect = current_user.contacts.receiving.where(c[:id].not_in(@contacts_in_aspect.map(&:id))).includes(:person => :profile).all.sort! { |x, y| x.person.name <=> y.person.name } + @contacts_not_in_aspect = current_user.contacts.receiving.where(c[:id].not_in(@contacts_in_aspect.map(&:id))).includes(:aspect_memberships, :person => :profile).all.sort! { |x, y| x.person.name <=> y.person.name } end @contacts = @contacts_in_aspect + @contacts_not_in_aspect diff --git a/app/controllers/contacts_controller.rb b/app/controllers/contacts_controller.rb index 8336f7f70..f3fbab9bb 100644 --- a/app/controllers/contacts_controller.rb +++ b/app/controllers/contacts_controller.rb @@ -37,7 +37,7 @@ class ContactsController < ApplicationController end def sharing - @contacts = current_user.contacts.sharing.includes(:aspects) + @contacts = current_user.contacts.sharing.includes(:aspect_memberships) render :layout => false end end diff --git a/app/helpers/aspect_global_helper.rb b/app/helpers/aspect_global_helper.rb index 66f2a9976..d9921c375 100644 --- a/app/helpers/aspect_global_helper.rb +++ b/app/helpers/aspect_global_helper.rb @@ -83,7 +83,7 @@ module AspectGlobalHelper end def aspect_dropdown_list_item(aspect, contact, person) - checked = contact.persisted? && contact.aspects.include?(aspect) ? "checked=\"checked\"" : "" + checked = (contact.persisted? && contact.aspect_memberships.detect{ |am| am.aspect_id == aspect.id}) ? "checked=\"checked\"" : "" str = "