`gem install activerecord-postgresql-adapter`はproduction用にGemfileを切る
herokuにRails3.2.1アプリをpushしようとすると,
adapter: `gem install activerecord-postgresql-adapter` (pg is not part of the bundle. Add it to Gemfile.) (RuntimeError)
が出てうまくいかない.
ここにはいくつもの罠がある.
- "activerecord-postgresql-adapter"というgemは存在しない.gem install pgでないとだめ.(参考:RailsからPostgreSQLに繋がらない〜 - Stellaqua - TOMの技術日記)
- ふつうにgem installすると失敗する.--with-pg-dirでPostgresのインストールしてあるディレクトリを指定する必要がある.(参考:libpq-fe.hが見つからない - 屑プログラマの憂鬱)
- 上記のことはすべて関係なく,Gemfileの記述を以下のように変えないとダメ.
group :production do gem 'pg' end group :development, :test do gem 'sqlite3' end
(参考:HerokuでRails 3.1.3 でdeployするまで - リンゴの水やり?(はてな))
このように書きかえて,
$ bundle install --without production
をしてはじめて成功する.