improve relations and scopes

This commit is contained in:
João Victor Geonizeli
2022-02-28 10:33:44 -03:00
parent e465123190
commit 7ea2d65fef
4 changed files with 62 additions and 0 deletions

View File

@@ -9,4 +9,9 @@ class User < ApplicationRecord
}
has_many :posts
has_many :user_follows_following, class_name: 'UserFollow', foreign_key: :follower_id
has_many :user_follows_followers, class_name: 'UserFollow', foreign_key: :followed_id
has_many :following, through: :user_follows_following, source: :followed
has_many :followers, through: :user_follows_followers, source: :follower
end