Mac OSX マシン用の postgres.app をダウンロードしました。postgres アプリに付属の postgres DB を接続して使用する Rails アプリがあります。
現在、postgres データベース インスタンスへの接続を試行するために、純粋な Ruby テスト スクリプト (Rails ではなく、純粋な Ruby であり、Active Record でさえありません) を作成しています。これらは、これを設定するために私が従った手順です
1) ran this command on the terminal:
gem install pg -- --with-pg-config=/Applications/Postgres.app/Contents/MacOS/bin/pg_config
2) Added this code to the test script:
#!/usr/bin/env ruby
#encoding: utf-8
require "pg"
@conn = PG.connect(
:dbname => 'oData',
:user => 'am',
:password => '')
@conn.exec("CREATE TABLE programs (id serial NOT NULL, name character varying(255);");
私はこのリンクからこれを得ました
このスクリプトを実行すると、次のエラーが表示されます。
/Users/am/.rvm/gems/ruby-2.0.0-p247/gems/pg-0.16.0/lib/pg.rb:38:in `initialize': could
not connect to server: No such file or directory (PG::ConnectionBad)
Is the server running locally and accepting
connections on Unix domain socket "/var/pgsql_socket/.s.PGSQL.5432"?
私のデバッグの取り組み:
My postgres.app is up and running.
I looked at the pg gem [documentation][2] and my syntax seemed OK.
The location of my postgres DB is entered in my bash script like so
PATH="/Applications/Postgres.app/Contents/MacOS/bin:$PATH"
次に何をすべきかわからない。助けていただければ幸いです、ありがとう。