Commit 51cb598ffd8665e20ac3f53a8b61da66fcc52d6b
1 parent
a4dae44e
Moves relations to concerns
Signed-off-by: Gabriel Silva <gabriel93.silva@gmail.com>
Showing
6 changed files
with
9 additions
and
10 deletions
Show diff stats
app/models/concerns/followable.rb
1 | 1 | module Followable |
2 | 2 | extend ActiveSupport::Concern |
3 | 3 | |
4 | + included do | |
5 | + has_many :profile_followers, :as => :profile | |
6 | + has_many :circles, :through => :profile_followers | |
7 | + end | |
8 | + | |
4 | 9 | def followers |
5 | 10 | person_followers = Person.joins(:owned_circles).merge(circles).uniq |
6 | 11 | external_person_followers = ExternalPerson.joins(:owned_circles).merge(circles).uniq | ... | ... |
app/models/concerns/follower.rb
app/models/external_person.rb
... | ... | @@ -5,10 +5,7 @@ class ExternalPerson < ExternalProfile |
5 | 5 | include ProfileEntity |
6 | 6 | include Follower |
7 | 7 | |
8 | - has_many :owned_circles, as: :owner, :class_name => "Circle" | |
9 | - | |
10 | 8 | validates_uniqueness_of :identifier, scope: :source |
11 | - | |
12 | 9 | validates_presence_of :source, :email, :created_at |
13 | 10 | |
14 | 11 | attr_accessible :source, :email, :created_at | ... | ... |
app/models/external_profile.rb
app/models/person.rb
... | ... | @@ -94,7 +94,6 @@ class Person < Profile |
94 | 94 | has_many :following_articles, :class_name => 'Article', :through => :article_followers, :source => :article |
95 | 95 | has_many :friendships, :dependent => :destroy |
96 | 96 | has_many :friends, :class_name => 'Person', :through => :friendships |
97 | - has_many :owned_circles, as: :owner, :class_name => 'Circle' | |
98 | 97 | |
99 | 98 | scope :online, -> { |
100 | 99 | joins(:user).where("users.chat_status != '' AND users.chat_status_at >= ?", DateTime.now - User.expires_chat_status_every.minutes) | ... | ... |
app/models/profile.rb
... | ... | @@ -235,9 +235,6 @@ class Profile < ApplicationRecord |
235 | 235 | |
236 | 236 | has_many :email_templates, :foreign_key => :owner_id |
237 | 237 | |
238 | - has_many :profile_followers, :as => :profile | |
239 | - has_many :circles, :through => :profile_followers | |
240 | - | |
241 | 238 | # has_many :followers, -> { uniq }, :through => :profile_followers, :source => :person |
242 | 239 | |
243 | 240 | # Although this should be a has_one relation, there are no non-silly names for | ... | ... |