Answer the question
In order to leave comments, you need to log in
How to make a :includes query via a belongs_to relation with conditions on each table?
There is a certain user Ivan.
You need to download all of Ivan's undeleted and unblocked comments that are left for unblocked and undeleted posts.
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) }
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question