Commit d45e25860effdfa9a83db963aaa75def1f735f18

Authored by Dylan Guedes
1 parent aa37360c

Fixes reverted commit, adds new sti table and makes it a follower

app/models/concerns/follower.rb
... ... @@ -2,22 +2,12 @@ module Follower
2 2 extend ActiveSupport::Concern
3 3  
4 4 def follow(profile, circles)
5   - puts "follow..."
6 5 circles = [circles] unless circles.is_a?(Array)
7 6 circles.each do |new_circle|
8   -<<<<<<< HEAD
9 7 next if new_circle.owner != self || !profile.kind_of?(new_circle.profile_type.constantize)
10   -=======
11   - puts "seguindo alguen..."
12   - puts "profile_type: #{new_circle.profile_type}, class_name: #{profile.class.name}"
13   - puts "new_circle.person: #{new_circle.person}, self: #{self}"
14 8 if (new_circle.person != self && !(self.kind_of?(new_circle.person.class)) || new_circle.profile_type != profile.class.name)
15 9 next
16 10 end
17   - puts '*20'*20
18   - puts "CHEGOU NO PROFILE FOLLOWER"
19   - puts '*20'*20
20   ->>>>>>> parent of bfbd548... Revert "Adds new ExternalProfile module and refactor ExternalPerson"
21 11 ProfileFollower.create(profile: profile, circle: new_circle)
22 12 end
23 13 end
... ...
app/models/external_person.rb
... ... @@ -3,15 +3,11 @@ class ExternalPerson &lt; ExternalProfile
3 3  
4 4 include Human
5 5 include ProfileEntity
6   -<<<<<<< HEAD
7 6 include Follower
8   - include Followable
9 7  
10 8 has_many :profile_followers, :as => :profile
11 9 has_many :circles, :through => :profile_followers
12 10 has_many :owned_circles, as: :owner, :class_name => "Circle"
13   -=======
14   ->>>>>>> parent of bfbd548... Revert "Adds new ExternalProfile module and refactor ExternalPerson"
15 11  
16 12 validates_uniqueness_of :identifier, scope: :source
17 13  
... ... @@ -138,7 +134,6 @@ class ExternalPerson &lt; ExternalProfile
138 134 }
139 135 end
140 136  
141   -<<<<<<< HEAD
142 137 # External Person should respond to all methods in Person and Profile
143 138 def person_instance_methods
144 139 methods_and_responses = {
... ... @@ -272,6 +267,4 @@ class ExternalPerson &lt; ExternalProfile
272 267 end
273 268 derivated_methods
274 269 end
275   -=======
276   ->>>>>>> parent of bfbd548... Revert "Adds new ExternalProfile module and refactor ExternalPerson"
277 270 end
... ...
app/models/external_profile.rb
1 1 class ExternalProfile < ActiveRecord::Base
2 2  
3   - include Follower
  3 + include Followable
4 4  
5 5 has_many :circles, as: :person
6 6  
... ...
db/migrate/20160822110424_rename_external_people_to_external_profiles.rb
... ... @@ -1,9 +0,0 @@
1   -class RenameExternalPeopleToExternalProfiles < ActiveRecord::Migration
2   - def up
3   - rename_table :external_people, :external_profiles
4   - end
5   -
6   - def down
7   - rename_table :external_profiles, :external_people
8   - end
9   -end
db/migrate/20160829170524_rename_external_people_to_external_profiles.rb 0 → 100644
... ... @@ -0,0 +1,9 @@
  1 +class RenameExternalPeopleToExternalProfiles < ActiveRecord::Migration
  2 + def up
  3 + rename_table :external_people, :external_profiles
  4 + end
  5 +
  6 + def down
  7 + rename_table :external_profiles, :external_people
  8 + end
  9 +end
... ...
db/migrate/20160829185118_add_type_to_external_profile.rb 0 → 100644
... ... @@ -0,0 +1,9 @@
  1 +class AddTypeToExternalProfile < ActiveRecord::Migration
  2 + def up
  3 + add_column :external_profiles, :type, :string, default: "ExternalProfile"
  4 + end
  5 +
  6 + def down
  7 + remove_column :external_profiles, :type
  8 + end
  9 +end
... ...