【发布时间】:2011-11-06 22:22:00
【问题描述】:
我有一个基本应用程序,我正在尝试将其部署到 Heroku。我可以用 git 将它推送到 Heroku,它会显示默认的 Rails 欢迎页面,但是当我尝试访问任何子页面时,(当我使用 rails server 在本地服务器上部署时工作的页面)我收到“出现问题”消息.
我调出日志,收到来自服务器的 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 install pg 和bundle install 之后,我确实将gem 'pg' 添加到了Gemfile。另外,我尝试了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-adapter 作为可能的替代方案。我用
更新了 Gemfilegroup :production, :staging do
gem 'pg'
end
和database.yml文件
production:
adapter: jdbcpostgresql
当我 heroku rake db:migrate 时,它仍然给我消息告诉我安装 postgresql 适配器
【问题讨论】:
标签: ruby-on-rails deployment heroku