我有一个在heroku中托管的rails应用程序.我有一个带有内容列的问题表.内容列包含问题的单词.例如,如果您查询. Question.first.content,你会得到“你好,你好吗?”.我总共有8个问题.我想手动进入数据库并更改这些问题.
我尝试使用此命令在heroku上运行终端:
heroku pg:psql
我使用此查询来更改记录的内容列
UPDATE Questions SET content="What country does this story orginate? (Japan)"
但是我收到此错误消息:
ERROR: column “What country does this story orginate? (Japan)” does not exist
LINE 2: SET content=”What country does this story orginate? (Japan)”…
更改问题内容列的正确查询是什么?
解决方法
事实证明我可以做heroku运行控制台.一旦进入控制台,我就可以进行活动记录查询,例如Question.find(1).update_attributes(:content =>’你好吗?’)并更新.无论出于何种原因,heroku运行rails控制台都没有使用活动记录查询更新记录,但只是返回查询成功.