Ruby on rails heroku控制台不工作
我是RubyonRails环境的新手。 我使用seeds.rb将数据库和数据迁移到heroku。在运行TableName.all的heroku服务器中,填充heroku postgres中存在的所有数据。当我试着像这样运行命令时Ruby on rails heroku控制台不工作,ruby-on-rails,sqlite,postgresql,heroku,Ruby On Rails,Sqlite,Postgresql,Heroku,我是RubyonRails环境的新手。 我使用seeds.rb将数据库和数据迁移到heroku。在运行TableName.all的heroku服务器中,填充heroku postgres中存在的所有数据。当我试着像这样运行命令时 TableName.select("Distinct(Category)") 我犯了一个错误 Column TableName.Category does not exist. 我试着在专栏中加入changin,但没有成功。请告诉我这里出了什么问题 提前谢谢 编辑
TableName.select("Distinct(Category)")
我犯了一个错误
Column TableName.Category does not exist.
我试着在专栏中加入changin,但没有成功。请告诉我这里出了什么问题
提前谢谢
编辑
在我的开发服务器上,它工作正常。开发人员站点上没有问题。我正在开发网站上使用SQLite
编辑**
以下是以下内容的续集:
#rails console
>>Recall.all
SELECT "recalls".* From "recalls"
=>[#<Recall id:1, Category: "******",......>]
>>Recall.select("Distinct(Category)")
SELECT DISTINCT(Category) From recalls
=>[#<Recall Category: "Foods">,#<Recall Category: "Consumer Products">]
#heroku run console
>>Recall.all
SELECT "recalls".* From "recalls"
=><Recall id:1, Category: "******",......>
>>Recall.select("Distinct(Category)")
Recall Load <2.5ms> SELECT DISTINCT(Category) FROM "recalls"
PGError: ERROR: column "category" does not exist
LINE 1:SELECT DISTINCT(Category) FROM "recalls"
^
:SELECT DISTINCT(Category) FROM "recalls"
ActiveRecord::StatementInvalid: PGError: ERROR: column "category" does not exist
LINE 1:SELECT DISTINCT(Category) FROM "recalls"
:SELECT DISTINCT(Category) FROM "recalls"
您似乎没有在Heroku上正确设置数据库表。您是否执行了类似于运行heroku run db:migrate的操作 你为什么不调查一下?你试过heroku pg:psql吗?看
另外,您真的不应该使用SQLite—它不是同一个数据库—并且SQL不是跨数据库的标准。你会在某个时候遇到一个非常微妙的数据库错误。我找到了答案。这是逃逸序列问题。 下面是我如何修复的
Recall.select("DISTINCT(\"Category\")")
关于这个问题
请显示正在运行的SQL的全文。您可以从Rails日志中获取它。