Skip to content
Browse files

Show only contacts with relation_customs

  • Loading branch information...
1 parent 1a95631 commit f9b11d7917a27bd925a3a5566ced9d26c36c7f9c @atd atd committed Jul 11, 2011
Showing with 5 additions and 5 deletions.
  1. +4 −4 app/models/actor.rb
  2. +1 −1 app/models/relation.rb
View
8 app/models/actor.rb
@@ -161,10 +161,12 @@ def relation_public
# Options:
# * type: Filter by the class of the contacts.
# * direction: sent or received
- # * relations: Restrict the relations of considered ties
+ # * relations: Restrict the relations of considered ties. Defaults to {Relation::Custom subject's custom relations}
# * include_self: False by default, don't include this actor as subject even they have ties with themselves.
#
def contact_actors(options = {})
+ options[:relations] ||= relation_customs.to_a
+
subject_types = Array(options[:type] || self.class.subtypes)
subject_classes = subject_types.map{ |s| s.to_s.classify }
@@ -186,9 +188,7 @@ def contact_actors(options = {})
as = as.where("actors.id != ?", self.id)
end
- if options[:relations].present?
- as = as.joins(:ties).merge(Tie.related_by(options[:relations]))
- end
+ as = as.joins(:received_ties).merge(Tie.related_by(options[:relations]))
as
end
View
2 app/models/relation.rb
@@ -57,7 +57,7 @@ def normalize(r, options = {})
when Array
r.map{ |e| Relation.normalize(e, options) }
else
- raise "Unable to normalize relation #{ r.inspect }"
+ raise "Unable to normalize relation #{ r.class }: #{ r.inspect }"
end
end

0 comments on commit f9b11d7

Please sign in to comment.
Something went wrong with that request. Please try again.