2013-06-26 42 views
0

我是在轨道环境中的红宝石新手。 我使用seeds.rb将我的数据库与数据一起迁移到heroku。在heroku服务器上运行TableName.all填充heroku postgres中的所有数据。当我尝试像heroku控制台明显不工作

TableName.select("Distinct(Category)") 

运行命令我得到错误

Column TableName.Category does not exist. 

我尝试了变化列,但没有奏效。请让我知道这里出了什么问题。

在此先感谢

编辑

在我的dev的服务器其工作正常。在开发网站上没有问题。我使用的开发站点

编辑**

这里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" 
+0

请表明是越来越运行SQL的全文。你可以从你的Rails日志中获得它。 –

回答

1

好像你还没有建立数据库表中正确地在Heroku。你有没有做类似跑heroku run db:migrate

你为什么不调查?你有没有试过heroku pg:psql?见here

此外,你真的不应该使用SQLite--它不是同一个数据库 - 并且SQL在数据库中不是标准的。某些时候你会碰到一个非常微妙的数据库错误。