I have a line in my code as show below...
injury.player_extract.player
I'm getting a notification from a gem called, bullet that there is an n+1 query detected. Now there is an association from injury to player extract, and then player_extract to player -- which I'll outline below. I've tried adding -> { includes: player}
as that's what bullet recommended but I still receive the error. Can anyone explain why I would still be receiving it?
Associations
injury.rb
belongs_to :player_extract, -> { includes :player }, class_name: 'PlayerExtract', foreign_key: 'Playerid', primary_key: 'Playerid'
player_extract.rb
belongs_to :player, foreign_key: 'Playerid', primary_key: 'leagueid'
player.rb
has_one :player_extract, class_name: 'PlayerExtract', foreign_key: 'Playerid', primary_key: 'leagueid'