0
我有3個型號:作家,書,頁。導軌訪問所有has_many通過記錄
Writer has_many :books
Writer has_many :pages, through: :books
Book has_many :pages
我想顯示所有屬於通過這本書作家的頁面,但它給出了一個錯誤:
Writer.first.books #=> works, shows all writer books
Book.first.pages #=> works, shows all book pages
Writer.first.books.pages #=> does not work, must in theory display all pages that belong to the writer
什麼是顯示所有網頁的最佳方式,使用each do |x|
除外?