Is it possible to get the has_many records from an ActiveRecord::Relation?
i.e. Book.where(fiction: true).pages
as opposed to Book.where(fiction: true).collect { |book| book.pages }
Ideally I'd like to be able to get all the records using one ActiveRecord query, so I don't have to build up the array in memory, and make the code a little cleaner, especially when the relationship has multiple levels (i.e. Book.where(fiction: true).pages.words
Well the below,
can be written as :
Similar way :