I need to preload associations of the model with complex conditions. NO, includes
doesn't work for me. It generate wrong SQL for my task.
I take a look to the ActiveRecord::Associations::Preloader
and find that he take an preload_scope
argument:
http://apidock.com/rails/v4.2.1/ActiveRecord/Associations/Preloader/preload
def preload(records, associations, preload_scope = nil)
# ...
end
But I can't find any example using it. What is preload_scope
in this case? And how I can use it for filtering associations?
Thanks!