Reputation: 2508
I am facing the following issue. My game
object has two associated players
, as we can see:
=> game.players.count
2
However, the pluck
method is returning duplicated values:
=> game.players.pluck :name
["Alice", "Alice", "Bob", "Bob"]
Both Game
and Player
extend ActiveRecord::Base
. I have absolutely no idea of what is really going on here.
Relevant gems:
rails 4.2.8
mysql2 0.3.21
Any clue about what could be going on? Thanks in advance.
Upvotes: 3
Views: 1002
Reputation: 2508
I finally found out that the Player
model has a default_scope
that includes the translations from globalize3
gem:
default_scope { includes(:translations) }
I removed the default scope and it started working as expected.
Upvotes: 5