Find records in deeply nested associations with rails
问题 I have the following models: class Book < ApplicationRecord has_many :chapters end class Chapter < ApplicationRecord belongs_to :book has_many :pages end class Page < ApplicationRecord belongs_to :chapter has_many :paragraphs end class Paragrpah < ApplicationRecord belongs_to :page end Now I want to get a list of all paragraphs in a specific book. Something like: @parapgraphs = Paragraph.pages.chapters.book.where(:title => 'My Book') When I do this, I get: undefined method 'chapters' for