请安装postgresql适配器:`gem install activerecord-postgresql-adapter`

时间:2013-07-24 15:29:25

标签: ruby-on-rails postgresql deployment capistrano

我正在尝试将rails 3.2 ruby​​ 1.9.3 app部署到数字海洋。 在执行cap deploy:setupcap deploy:checkcap deploy之后,我收到以下错误:

$ gem install activerecord-postgresql-adapter
  * ←[33mexecuting "cd -- /home/deployer/apps/csd3/releases/20130724142600 && RA
ILS_ENV=production RAILS_GROUPS=assets bundle exec rake assets:precompile"←[0m
    servers: ["192.241.141.56"]
    [192.241.141.56] executing command
 ** [out :: 192.241.141.56] rake aborted! 
 ** [out :: 192.241.141.56] Please install the postgresql adapter: `gem install
activerecord-postgresql-adapter` (pg is not part of the bundle. Add it to Gemfil
e.)

我在服务器上运行gem install activerecord-postgresql-adapter并完成。但是,当我进行封顶部署时,我会得到相同的消息。我发现问题可能在database.yml文件中,但似乎没问题。

development:
  adapter: sqlite3
  database: db/development.sqlite3
  pool: 5
  timeout: 5000

test: 
  adapter: sqlite3
  database: db/test.sqlite3
  pool: 5
  timeout: 5000

production:
  adapter: postgresql
  encoding: unicode
  database: chodae_database
  host: 192.241.141.56
  pool: 5
  username: chodae
  password:

和Gemfile:

group :development do
  gem 'quiet_assets', '1.0.2'
  gem 'sqlite3', '1.3.7'
  gem 'thin', '1.5.0'
  gem 'better_errors', '0.7.0'
  gem 'binding_of_caller', '0.7.1'
  gem 'meta_request', '0.2.2'
  gem 'wirble', '0.1.3'
  gem 'hirb', '0.7.1'
  gem 'populator3', '0.2.7'
  gem 'faker', '1.1.2'
  gem 'localtunnel'
  gem 'capistrano'
end

group :production do
  gem 'pg', '0.15.1'
  gem 'pg_search', '0.6.2'
  gem "nginx", '0.0.2'
  gem "passenger", "~> 4.0.10"
end

我该如何解决这个问题?

1 个答案:

答案 0 :(得分:2)

首先,最佳做法是在所有环境中使用相同的数据库 你能在服务器上运行RAILS_ENV=production bundle exec gem install pg吗?

问题似乎是在运行

时资产组中缺少pg gem
RAILS_ENV=production RAILS_GROUPS=assets bundle exec rake assets:precompile