From 4ba58d8132cb3687e4b00ef727170bd76b6259a7 Mon Sep 17 00:00:00 2001 From: Raphael Date: Mon, 17 Jan 2011 14:17:37 -0800 Subject: [PATCH] Simplify hashes_for_contacts --- app/controllers/aspects_controller.rb | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) 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 = {}