gpt4 book ai didi

Rails模型中Mysql归档关键字

转载 作者:行者123 更新时间:2023-11-30 01:09:03 24 4
gpt4 key购买 nike

现在我有了一个 Controller :

class CommonController < ApplicationController
def location
@locations=Location.select(:key)
render json: @locations
end
end

我的数据库是mysqlkey是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` 

那我该怎么办?

最佳答案

我明白了。就这样写:

@locations=Location.select('`key`')

关于Rails模型中Mysql归档关键字,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19583344/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com