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

xslt - Substring before throwing error -

Google Cloud Bigtable Durability/Availability Guarantees -

Android M doze mode and "native" posix socket freezing up -