diff --git a/app/controllers/aspects_controller.rb b/app/controllers/aspects_controller.rb index 8c415210e..b2afa078f 100644 --- a/app/controllers/aspects_controller.rb +++ b/app/controllers/aspects_controller.rb @@ -83,7 +83,7 @@ class AspectsController < ApplicationController render :file => "#{Rails.root}/public/404.html", :layout => false, :status => 404 else @aspect_ids = [@aspect.id] - @aspect_contacts = hashes_for_contacts @aspect.contacts.where(:pending => false).all + @aspect_contacts = hashes_for_contacts @aspect.contacts.where(:pending => false) @aspect_contacts_count = @aspect_contacts.count @all_contacts = hashes_for_contacts @contacts @@ -187,10 +187,7 @@ class AspectsController < ApplicationController private def hashes_for_contacts contacts - people = Person.where(:id => contacts.map{|c| c.person_id}) - people_hash = {} - people.each{|p| people_hash[p.id] = p} - contacts.map{|c| {:contact => c, :person => people_hash[c.person_id]}} + contacts.includes(:person).map{|c| {:contact => c, :person => c.person}} end def hashes_for_aspects aspects, contacts, opts = {}