User
has_many :posts
has_many: comments
Post
belongs_to :user
has_many :comments
scope :active, -> { where(deleted: false, blocked: false) }
Comment
belongs_to :user
belongs_to :post
scope :active, -> { where(deleted: false, blocked: false) }
Comment.includes(:user, :post)
.where(posts: { deleted: false, blocked: false })
.where(comments: { deleted: false, blocked: false })
.where(users: { name: 'Ivan' })