ruby-on-rails-3 - 启动 rails3.1 应用时出现 Heroku 错误,缺少 postgres gem

标签 ruby-on-rails-3 postgresql heroku

我正在尝试部署到 heroku。

Rails 3.1.0.rc4,

我从 Heroku 日志中得到以下错误:

Starting process with command: `thin -p 48902 -e production -R /home/heroku_rack/heroku.ru start`
2011-06-20T11:25:44+00:00 app[web.1]: /app/.bundle/gems/ruby/1.9.1/gems/activerecord-3.1.0.rc4/lib/active_record/connection_adapters/abstract/connection_specification.rb:71:in `rescue in establish_connection': Please install the postgresql adapter: `gem install activerecord-postgresql-adapter` (pg is not part of the bundle. Add it to Gemfile.) (RuntimeError)

我尝试安装 activerecord-postgresql-adapter 但随后出现此错误:

Could not find gem 'activerecord-postgresql-adapter (>= 0)' in any of the gem sources listed in your Gemfile.

所以我尝试将其添加到我的 gem 文件中

gem 'pg'

产生此错误的原因:

Installing pg (0.11.0) with native extensions /Users/imac/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/site_ruby/1.9.1/rubygems/installer.rb:533:in `rescue in block in build_extensions': ERROR: Failed to build gem native extension. (Gem::Installer::ExtensionBuildError)

有什么想法吗?

最佳答案

您不必在本地安装 Postgres。在你的 Gemfile 中,按照 johnny-grass 的建议,将 'pg' 放在 :production 组中,然后当你运行 bundle 时,只需指定 --without production,就像这样:

bundle --without production

不幸的是,当你运行 bundler 时你必须记住这个参数,但至少你不必在本地安装和维护 postgres。

请注意,Heroku“强烈建议不要”使用 sqlite,称“您的生产和开发环境应尽可能接近相同”http://devcenter.heroku.com/articles/rails3

关于ruby-on-rails-3 - 启动 rails3.1 应用时出现 Heroku 错误,缺少 postgres gem,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6410623/

相关文章:

postgresql - 如何在 PostgreSQL 中获取唯一的日期范围?

ruby-on-rails - 在 Rails 和 PostgreSQL 中完全忽略时区

javascript - Ember - 使用 heroku 强制 https

Heroku Redis 上的 SSL 认证验证失败

ruby-on-rails-3 - Rails3 应用程序尝试连接错误的数据库用户

ruby-on-rails - 从 Rails 中的数组中收集唯一的事件记录对象?

ruby-on-rails - Ruby on Rails 的社交媒体共享按钮 Gem

macos - 无法在 OSX Mavericks 上重启 Postgres - 'Operation already in progress'?

java - 在 Heroku 上部署 Play Scala 应用程序

ruby-on-rails - 3.1 Flash 文件应该存放在哪里?