Rails ignores constants in SQL SELECT statement
问题 Is there a trick required to make Rails recognize constants in a SQL select statement? For example, the following SQL statement is valid: SELECT id, name, 1 AS constant FROM table_name And I would expect the results to have three columns returned: id , name and constant . The value in the constant column would always be 1. However, in Rails if I try to do the same thing the constant column gets dropped using Model.find_by_sql : TableName.find_by_sql("SELECT id, name, 1 AS constant FROM table