2011-11-06 104 views
2

我有一個基本的應用程序,我試圖部署到Heroku。我可以使用git將它推送到Heroku,並顯示默認的Rails歡迎頁面,但是當我嘗試訪問任何子頁面時(頁面在部署在本地服務器上時工作,rails server),我收到「出錯的消息」消息。Heroku部署的數據庫問題

我拉起了日誌,我得到了500個來自服務器的響應和大量ActiveRecord::ConnectionNotEstablished消息,這似乎是連接到數據庫的問題。

此外,當我試圖運行heroku rake db:migrate,我收到以下錯誤

rake aborted! 
Please install the postgresql adapter: `gem install activerecord-postgresql-adap 
ter` (pg is not part of the bundle. Add it to Gemfile.) 

Tasks: TOP => db:migrate => db:load_config 
(See full trace by running task with --trace) 

按照上面的建議,我確實添加了gem 'pg'到Gemfile中運行gem install pg然後bundle install後。另外,我想gem install activerecord-postgresql-adapter(在Windows上),並得到

ERROR: Could not find a valid gem 'activerecord-postgresql-adapter' (>= 0) in a 
ny repository 
ERROR: Possible alternatives: activerecord-jdbcpostgresql-adapter, activerecord 
-postgis-adapter, activerecord-jdbcmssql-adapter, activerecord-jdbcmysql-adapter 
, activerecord-postgresql-cursors 

從我正在讀的書的建議,我跑heroku db:push和它競爭沒有錯誤,但它並沒有解決網頁的問題一旦應用推向Heroku,不會呈現。

更新:我試過安裝activerecord-jdbcpostgresql適配器作爲建議作爲一種可能的選擇。我更新了的Gemfile與

group :production, :staging do 
    gem 'pg' 
end 

production: 
    adapter: jdbcpostgresql 

database.yml文件,當我heroku rake db:migrate,它仍然給我的消息告訴我要安裝PostgreSQL適配器

回答

0

如果heroku rake db:migrate運行沒有錯誤,那麼你的數據庫連接信息是正確的。這很可能是另一個錯誤,阻止頁面正確呈現。如果您在發出請求時尾隨您的heroku日誌,您是否仍然收到相同的數據庫錯誤?我懷疑你會發現這是你需要修復的另一個錯誤。

+0

對不起,我在那裏粘貼了錯誤的命令。我更新了它 –

+0

您的適配器需要'postgresql',而不是'jdbcpostgresql';後者用於JRuby部署,Heroku不運行。嘗試只需安裝pg gem,然後使用'adapter:postgresql'。 –