I have the follow set up in my models:
class Project < ApplicationRecord
has_many :plans
end
class Plan < ApplicationRecord
belongs_to :project
has_many :documents
end
class Document < ApplicationRecord
belongs_to :plan
end
I'm trying to make a query in which I can easily return all nested associated records. For example, I want to be able to do something like: Project.documents and get all documents for a project. I've tried this with an includes like so:
Project.includes({plans: [:documents]})
but that doesn't appear to give me what I want when I call Project.documents. I really only want all documents for a project, so don't really need to include plans. Is there an easy way todo this in Rails 6?