I need to pre-establish model associations with complex conditions. NO, includes does not work for me. It generates the wrong SQL for my task.
I look at ActiveRecord::Associations::Preloader and find that it takes the preload_scope argument:
http://apidock.com/rails/v4.2.1/ActiveRecord/Associations/Preloader/preload
def preload(records, associations, preload_scope = nil)
But I can not find any example of its use. What is preload_scope in this case? And how can I use it to filter associations? Thanks!
source share