While selecting a column name with a different name like so
=> t = TeamMapping.select('team_id as team').last
=> t[:team]
> 2
works. But if I add another table as an included and referenced in query, suddenly this behaviour breaks.
=> t = TeamMapping.includes(:user).references(:user).select('team_id as team').last
=> t[:team]
> nil
Please note that user
table has no column whatsoever with the name team
. I was not able to find anything relevant by searching on google. I would appreciate it if someone can explain what is happening behind the scenes.