Say I have a model Book with fields id, field1, _field2. I want to select only the fields relevant for my code, so I use, :field1). However, this returns a relation as follows: [<#Book id: 12345, field1: "val", _field2: "other_val">].

Can someone explain here why the select method returns fields starting with underscore even though these have not been passed as an argument? There is no mention of this behaviour in the method documentation.

Note my version of ActiveRecord is Underlying database is MySQL.

0 Answers