现在我有一个控制器:
class CommonController < ApplicationController
def location
@locations=Location.select(:key)
render json: @locations
end
end
我的数据库是mysql
,并且key
是 mysql 关键字。
但是我的表只是有一个名为key
当我运行动作时,我得到了错误:
Mysql2::Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'key FROM `locations`' at line 1: SELECT key FROM `locations`
所以我该怎么做?