Commit 63f25af12e0123a8401c6388bf6195beb29ad8eb

Authored by Larissa Reis
1 parent 80057103

Creates a circle for each friendship group

Showing 1 changed file with 5 additions and 1 deletions   Show diff stats
app/models/friendship.rb
... ... @@ -9,7 +9,11 @@ class Friendship < ApplicationRecord
9 9 after_create do |friendship|
10 10 Friendship.update_cache_counter(:friends_count, friendship.person, 1)
11 11 Friendship.update_cache_counter(:friends_count, friendship.friend, 1)
12   - friendship.person.follow(friendship.friend, Circle.find_or_create_by(:person => friendship.person, :name => (friendship.group.blank? ? 'friendships': friendship.group), :profile_type => 'Person'))
  12 +
  13 + circles = friendship.group.blank? ? ['friendships'] : friendship.group.split(',').map(&:strip)
  14 + circles.each do |circle|
  15 + friendship.person.follow(friendship.friend, Circle.find_or_create_by(:person => friendship.person, :name => circle, :profile_type => 'Person'))
  16 + end
13 17 end
14 18  
15 19 after_destroy do |friendship|
... ...