Commit 79b7d381 authored by Steven Hancock's avatar Steven Hancock
Browse files

Fix ActiveRecord queries with nested hashes

Rails 3.2.6 doesn't like them
parent a2ccf685
......@@ -69,10 +69,10 @@ class Contact < ActiveRecord::Base
def contacts
people = Person.arel_table
incoming_aspects = Aspect.joins(:contacts).where(
incoming_aspects = Aspect.where(
:user_id => self.person.owner_id,
:contacts_visible => true,
:contacts => {:person_id => self.user.person.id}).select('aspects.id')
:contacts_visible => true).joins(:contacts).where(
:contacts => {:person_id => self.user.person.id}).select('aspects.id')
incoming_aspect_ids = incoming_aspects.map{|a| a.id}
similar_contacts = Person.joins(:contacts => :aspect_memberships).where(
:aspect_memberships => {:aspect_id => incoming_aspect_ids}).where(people[:id].not_eq(self.user.person.id)).select('DISTINCT people.*')
......
......@@ -71,7 +71,8 @@ class Person < ActiveRecord::Base
# @note user is passed in here defensively
scope :all_from_aspects, lambda { |aspect_ids, user|
joins(:contacts => :aspect_memberships).
where(:contacts => {:user_id => user.id}, :aspect_memberships => {:aspect_id => aspect_ids})
where(:contacts => {:user_id => user.id}).
where(:aspect_memberships => {:aspect_id => aspect_ids})
}
scope :unique_from_aspects, lambda{ |aspect_ids, user|
......@@ -81,7 +82,7 @@ class Person < ActiveRecord::Base
#not defensive
scope :in_aspects, lambda { |aspect_ids|
joins(:contacts => :aspect_memberships).
where(:contacts => { :aspect_memberships => {:aspect_id => aspect_ids}})
where(:aspect_memberships => {:aspect_id => aspect_ids})
}
scope :profile_tagged_with, lambda{|tag_name| joins(:profile => :tags).where(:profile => {:tags => {:name => tag_name}}).where('profiles.searchable IS TRUE') }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment