尝试在Mac OS X上启动rails服务器时出现奇怪的PostgreSQL错误

时间:2012-06-29 01:38:41

标签: ruby-on-rails ruby-on-rails-3 postgresql rails-postgresql

我想让一个使用PostgreSQL的rails应用程序,但是发生了一些奇怪的事情。我的朋友能够安装PostgreSQL并执行:

sudo su
su postgres
createdb development

接着是

rails server

没有错误。但是,当我尝试这样做时,我得到一个奇怪的错误:

/Users/user/.rvm/gems/ruby-1.9.3-p194/gems/activerecord 3.2.5/lib/active_record/connection_adapters/postgresql_adapter.rb:1151:in `async_exec': PG::Error: ERROR:  relation "reports" does not exist (ActiveRecord::StatementInvalid) 

LINE 4:              WHERE a.attrelid = '"reports"'::regclass
                                    ^
:             SELECT a.attname, format_type(a.atttypid, a.atttypmod), d.adsrc, a.attnotnull
          FROM pg_attribute a LEFT JOIN pg_attrdef d
            ON a.attrelid = d.adrelid AND a.attnum = d.adnum
         WHERE a.attrelid = '"reports"'::regclass
           AND a.attnum > 0 AND NOT a.attisdropped
         ORDER BY a.attnum

请注意,“reports”是应用程序中的模型。

对于它的价值,database.yml文件如下所示:

development:
  adapter: postgresql
  encoding: unicode
  database: development
  pool: 5
  username: postgres
  password: post

(我不知道哪个池意味着什么,但我已经设置了postgres密码才能发布)

2 个答案:

答案 0 :(得分:2)

您运行rake db:migrate吗?

答案 1 :(得分:0)

WHERE a.attrelid = '"reports"'::regclass ...引用太多了。它应该是WHERE a.attrelid = 'reports'::regclass ...