Preload has_many associations with dynamic conditions

后端 未结 4 1999
旧巷少年郎
旧巷少年郎 2020-12-15 08:24

I have a Place model and an Event model. Places can have events that take place on a specific date.

How can I set up my associatio

4条回答
  •  难免孤独
    2020-12-15 09:01

    I have mentioned in some cases includes doesn't properly select eager loading method. There is an explanation of how this method work http://blog.arkency.com/2013/12/rails4-preloading/ . You can directly call eager_load(:events) an I think it will load your AR objects without n+1 problem.

提交回复
热议问题