Rails と Linux を数日のうちに始めるだけです... Heroku にデプロイしたいのですが、ローカル環境でも postgresql を使用するのがベスト プラクティスの 1 つです ... チュートリアルの 1 つに従って、サンプル アプリケーションを作成しました。
pg gemがインストールされました。バンドルのインストールは問題なく動作します。rake db:migrate
動作し、アプリケーション用のテーブルを作成しました。しかし... Railsページを実行しようとすると、次のエラーが発生します:
ActiveRecord::ConnectionNotEstablished
これは完全なトレースの終わりです:
> activerecord (3.2.3) lib/active_record/connection_adapters/abstract/connection_pool.rb:398:in `retrieve_connection'
activerecord (3.2.3) lib/active_record/connection_adapters/abstract/connection_specification.rb:168:in `retrieve_connection'
activerecord (3.2.3) lib/active_record/connection_adapters/abstract/connection_specification.rb:142:in `connection'
activerecord (3.2.3) lib/active_record/query_cache.rb:67:in `rescue in call'
activerecord (3.2.3) lib/active_record/query_cache.rb:61:in `call'
activerecord (3.2.3) lib/active_record/connection_adapters/abstract/connection_pool.rb:467:in `call'
actionpack (3.2.3) lib/action_dispatch/middleware/callbacks.rb:28:in `block in call'
activesupport (3.2.3) lib/active_support/callbacks.rb:405:in `_run__4423031206660944571__call__1711406629982304701__callbacks'
activesupport (3.2.3) lib/active_support/callbacks.rb:405:in `__run_callback'
activesupport (3.2.3) lib/active_support/callbacks.rb:385:in `_run_call_callbacks'
activesupport (3.2.3) lib/active_support/callbacks.rb:81:in `run_callbacks'
actionpack (3.2.3) lib/action_dispatch/middleware/callbacks.rb:27:in `call'
actionpack (3.2.3) lib/action_dispatch/middleware/reloader.rb:65:in `call'
actionpack (3.2.3) lib/action_dispatch/middleware/remote_ip.rb:31:in `call'
actionpack (3.2.3) lib/action_dispatch/middleware/debug_exceptions.rb:16:in `call'
actionpack (3.2.3) lib/action_dispatch/middleware/show_exceptions.rb:56:in `call'
私は自分のデータベースを見るためにpgadmin 3を使用しています。Ubuntuのユーザーと同じschallerという名前のユーザーを作成しました
私のdatabase.ymlファイル:
development:
adapter: postgresql
database: rails
encoding: unicode
username: schaller
password: password123
host: localhost
pool: 5
レールがpostgresに接続するために他に何を確認できますか?
編集:
webrick の netbeans で rails サーバーを起動するとエラーが発生する
2012-09-13 23:12:31 +0300 ActiveRecord::ConnectionNotEstablished (ActiveRecord::ConnectionNotEstablished): activerecord (3.2.3) lib/active_record/connection_adapters/abstract /connection_pool で 127.0.0.1 の GET "/ギャング/" を開始しました.rb:398:in
retrieve_connection' activerecord (3.2.3) lib/active_record/connection_adapters/abstract /connection_specification.rb:168:in
retrieve_connection' activerecord (3.2.3) lib/active_record/connection_adapters/abstract /connection_specification.rb:142:inconnection' activerecord (3.2.3) lib/active_record/query_cache.rb:67:in
rescue in call' ...
私の宝石ファイルの主なものを編集します:
gem 'rails', '3.2.3'
gem 'pg'
gem 'thin'
編集: postgresql 接続のログを追加する
[local]
2012-09-15 18:05:35 IDT LOG: connection received: host=127.0.0.1 port=44038
2012-09-15 18:05:35 IDT LOG: connection authorized: user=schaller database=postgres
2012-09-15 18:05:35 IDT LOG: connection received: host=127.0.0.1 port=44039
2012-09-15 18:05:35 IDT LOG: connection authorized: user=schaller database=rails
2012-09-15 18:07:26 IDT LOG: connection received: host=127.0.0.1 port=44048
2012-09-15 18:07:26 IDT LOG: connection authorized: user=schaller database=rails
とにかく、pgadmin 3 に接続し、コマンド「rake db:migrate」を実行するとログが書き込まれますが、Rails アプリを実行するとログが書き込まれません...
ありがとう