Module: RelationshipsHelper
- Defined in:
- app/helpers/relationships_helper.rb
Instance Method Summary collapse
Instance Method Details
#relationship_counts_for(person) ⇒ Object
22 23 24 |
# File 'app/helpers/relationships_helper.rb', line 22 def relationship_counts_for(person) person.relationships.includes(:relation).group(:relation).count end |
#relationships_struct(person) ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'app/helpers/relationships_helper.rb', line 3 def relationships_struct(person) single = [] grouped = [] counts = person.relationships.group(:relation_id).count counts.each do |id, count| if count > 5 grouped << {:relation => id, :count => count} else single << id # Run person.in_relationships(relationships) end end { :starred => person.relationships.starred, :single => single, :grouped => grouped } end |