Find by include nil object error in rails

前端 未结 3 1698
猫巷女王i
猫巷女王i 2021-01-24 03:22

I\'ve been trying hard to solve this problem but i really don\'t know what is happening. I have this small piece of code :

DiscoveredLocation.find_by_user_id(use         


        
3条回答
  •  萌比男神i
    2021-01-24 04:03

    You need to include the intermediate tables as well, otherwise there's no way to map boss_kills to DiscoveredLocations:

    DiscoveredLocation.find_by_user_id(user.id, :include => [:monsters, :boss_locations,:boss_kills])
    

    Also, check your development log to see the query that gets generated. If possible, post it here so we can determine whether it's missing one of the intermediate tables.

提交回复
热议问题