Simplify hashes_for_contacts
This commit is contained in:
parent
6410355d71
commit
4ba58d8132
1 changed files with 2 additions and 5 deletions
|
|
@ -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 = {}
|
||||
|
|
|
|||
Loading…
Reference in a new issue