ruby on rails - Get has_many from ActiveRecord::Relaiton -


is possible has_many records activerecord::relation?

i.e. book.where(fiction: true).pages opposed book.where(fiction: true).collect { |book| book.pages }

ideally i'd able records using 1 activerecord query, don't have build array in memory, , make code little cleaner, when relationship has multiple levels (i.e. book.where(fiction: true).pages.words

well below,

book.where(fiction: true).collect { |book| book.pages } 

can written :

page.joins(:book).where("books.fiction = ?", true) 

similar way :

word.joins(page: :book).where("books.fiction = ?", true) 

Comments

Popular posts from this blog

javascript - oscilloscope of speaker input stops rendering after a few seconds -

javascript - gulp-nodemon - nodejs restart after file change - Error: listen EADDRINUSE events.js:85 -

Fatal Python error: Py_Initialize: unable to load the file system codec. ImportError: No module named 'encodings' -