我想要得到一個與PostgreSQL一起工作的Rails應用程序,但發生了一些奇怪的事情。我的朋友們能夠安裝PostgreSQL和執行:試圖在Mac OS X上啓動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
注意,「報告」是在應用程序的模型。
對於它的價值,database.yml文件看起來是這樣的:
development:
adapter: postgresql
encoding: unicode
database: development
pool: 5
username: postgres
password: post
(我不知道是什麼意思池,但我已經把我的Postgres的密碼進行後)
您是否有任何初始化程序可以對您的模型執行任何操作? –
你是什麼意思?我不這麼認爲 – kyothine
聽起來像你的應用程序初始化中的東西正在嘗試使用你的'Report'類。該SQL是ActiveRecord的PostgreSQL適配器用來確定表的結構,錯誤表明您的數據庫中沒有「報告」。當你耙db:migrate時,你會遇到同樣的問題;因此您的應用程序初始化可能會發生故障*在*'db:migrate'之前會發生任何用處。你使用哪些插件?你有'config/initializers'中的任何東西嗎? –