1

Sinatra の開発データベースへの接続に問題があります。バックエンドを担当している担当者はニューヨークにいて、現在不在です。私はフロントエンドに精通していて、何か単純なものが欠けているのではないかと思っていました。

実稼働データベースは接続できますが、開発モードで起動しようとすると、ターミナルで大量のエラーが発生します。また、ポート 5432 を使用してシンを起動しようとしましたが、成功しませんでした。

何か案は? 追加した models.rb を編集

「ターミナル」

mdb|moreButton⚡ ⇒ ruby app.rb   
/Users/adam/.rvm/gems/ruby-1.9.3-p125@sinatra/gems/data_objects-0.10.10/lib/data_objects/connection.rb:79:in `initialize': could not connect to server: Connection     refused (DataObjects::ConnectionError)
    Is the server running on host "localhost" (127.0.0.1) and accepting
    TCP/IP connections on port 5432?
could not connect to server: Connection refused
    Is the server running on host "localhost" (::1) and accepting
    TCP/IP connections on port 5432?
could not connect to server: Connection refused
    Is the server running on host "localhost" (fe80::1) and accepting
    TCP/IP connections on port 5432?
    from /Users/adam/.rvm/gems/ruby-1.9.3-p125@sinatra/gems/data_objects-0.10.10/lib/data_objects/connection.rb:79:in `new'
    from /Users/adam/.rvm/gems/ruby-1.9.3-p125@sinatra/gems/data_objects-0.10.10/lib/data_objects/pooling.rb:181:in `block in new'
    from <internal:prelude>:10:in `synchronize'
    from /Users/adam/.rvm/gems/ruby-1.9.3-p125@sinatra/gems/data_objects-0.10.10/lib/data_objects/pooling.rb:176:in `new'
    from /Users/adam/.rvm/gems/ruby-1.9.3-p125@sinatra/gems/data_objects-0.10.10/lib/data_objects/pooling.rb:121:in `new'
    from /Users/adam/.rvm/gems/ruby-1.9.3-p125@sinatra/gems/data_objects-0.10.10/lib/data_objects/connection.rb:68:in `new'
    from /Users/adam/.rvm/gems/ruby-1.9.3-p125@sinatra/gems/dm-do-adapter-1.2.0/lib/dm-do-adapter/adapter.rb:251:in `open_connection'
    from /Users/adam/.rvm/gems/ruby-1.9.3-p125@sinatra/gems/dm-transactions-1.2.0/lib/dm-transactions/adapters/dm-do-adapter.rb:69:in `open_connection'
    from /Users/adam/.rvm/gems/ruby-1.9.3-p125@sinatra/gems/dm-do-adapter-1.2.0/lib/dm-do-adapter/adapter.rb:276:in `with_connection'
    from /Users/adam/.rvm/gems/ruby-1.9.3-p125@sinatra/gems/dm-do-adapter-1.2.0/lib/dm-do-adapter/adapter.rb:33:in `select'
    from /Users/adam/.rvm/gems/ruby-1.9.3-p125@sinatra/gems/dm-migrations-1.2.0/lib/dm-migrations/adapters/dm-postgres-adapter.rb:45:in `schema_name'
    from /Users/adam/.rvm/gems/ruby-1.9.3-p125@sinatra/gems/dm-migrations-1.2.0/lib/dm-migrations/adapters/dm-do-adapter.rb:26:in `storage_exists?'
    from /Users/adam/.rvm/gems/ruby-1.9.3-p125@sinatra/gems/dm-migrations-1.2.0/lib/dm-migrations/auto_migration.rb:65:in `storage_exists?'
    from /Users/adam/.rvm/gems/ruby-1.9.3-p125@sinatra/gems/dm-migrations-1.2.0/lib/dm-migrations/auto_migration.rb:120:in `storage_exists?'
    from /Users/adam/.rvm/gems/ruby-1.9.3-p125@sinatra/gems/dm-constraints-1.2.0/lib/data_mapper/constraints/migrations/model.rb:22:in `auto_migrate_constraints_down'
    from /Users/adam/.rvm/gems/ruby-1.9.3-p125@sinatra/gems/dm-constraints-1.2.0/lib/data_mapper/constraints/migrations/singleton_methods.rb:39:in `block in     auto_migrate_constraints_down'
    from /Users/adam/.rvm/gems/ruby-1.9.3-p125@sinatra/gems/dm-core-1.2.0/lib/dm-core/support/descendant_set.rb:64:in `block in each'
    from /Users/adam/.rvm/gems/ruby-1.9.3-p125@sinatra/gems/dm-core-1.2.0/lib/dm-core/support/subject_set.rb:210:in `block in each'
    from /Users/adam/.rvm/gems/ruby-1.9.3-p125@sinatra/gems/dm-core-1.2.0/lib/dm-core/support/ordered_set.rb:319:in `block in each'
    from /Users/adam/.rvm/gems/ruby-1.9.3-p125@sinatra/gems/dm-core-1.2.0/lib/dm-core/support/ordered_set.rb:319:in `each'
    from /Users/adam/.rvm/gems/ruby-1.9.3-p125@sinatra/gems/dm-core-1.2.0/lib/dm-core/support/ordered_set.rb:319:in `each'
    from /Users/adam/.rvm/gems/ruby-1.9.3-p125@sinatra/gems/dm-core-1.2.0/lib/dm-core/support/subject_set.rb:210:in `each'
    from /Users/adam/.rvm/gems/ruby-1.9.3-p125@sinatra/gems/dm-core-1.2.0/lib/dm-core/support/descendant_set.rb:63:in `each'
    from /Users/adam/.rvm/gems/ruby-1.9.3-p125@sinatra/gems/dm-constraints-1.2.0/lib/data_mapper/constraints/migrations/singleton_methods.rb:38:in     `auto_migrate_constraints_down'
    from /Users/adam/.rvm/gems/ruby-1.9.3-p125@sinatra/gems/dm-constraints-1.2.0/lib/data_mapper/constraints/migrations/singleton_methods.rb:7:in `auto_migrate!'
    from /Users/adam/Git/mdb/models.rb:403:in `<top (required)>'
    from /Users/adam/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
    from /Users/adam/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
    from app.rb:1:in `<main>'

私のジェムセット

mdb|moreButton⚡ ⇒ gem list

*** LOCAL GEMS ***

addressable (2.2.8)
backports (2.6.4, 2.6.1)
bcrypt-ruby (3.0.1)
bundler (1.1.5)
daemons (1.1.9)
data_mapper (1.2.0)
data_objects (0.10.10, 0.10.8)
dm-adjust (1.2.0)
dm-aggregates (1.2.0)
dm-constraints (1.2.0)
dm-core (1.2.0)
dm-do-adapter (1.2.0)
dm-migrations (1.2.0)
dm-postgres-adapter (1.2.0)
dm-serializer (1.2.2, 1.2.1)
dm-sqlite-adapter (1.2.0)
dm-timestamps (1.2.0)
dm-transactions (1.2.0)
dm-types (1.2.2, 1.2.1)
dm-validations (1.2.0)
do_postgres (0.10.10, 0.10.8)
do_sqlite3 (0.10.10, 0.10.8)
eventmachine (1.0.0, 0.12.10)
fastercsv (1.5.5)
hpricot (0.8.6)
json (1.7.5, 1.6.7)
json_pure (1.7.5, 1.6.7)
mime-types (1.19)
multi_json (1.3.6, 1.0.4)
multimap (1.1.2)
rack (1.4.1)
rack-protection (1.2.0)
rack-test (0.6.2, 0.6.1)
rake (0.9.2.2)
rest-client (1.6.7)
rubygems-bundler (1.0.3)
rvm (1.11.3.5)
sass (3.2.1)
shotgun (0.9)
sinatra (1.3.3, 1.3.2)
sinatra-contrib (1.3.1)
sinatra-reloader (1.0)
stringex (1.4.0, 1.3.3)
thin (1.5.0)
tilt (1.3.3)
time-ago-in-words (0.1.2)
uuidtools (2.1.3, 2.1.2)

app.rb gemfile

source 'http://rubygems.org'
gem 'sinatra'
gem 'data_mapper'
gem 'hpricot'
gem 'dm-core'
gem 'json'
gem 'dm-postgres-adapter'
gem 'dm-adjust'
gem 'time-ago-in-words'
gem 'sass'
gem 'rest-client'
gem 'multimap'

group :development do
  gem "dm-sqlite-adapter"
  gem 'sinatra-reloader'
end

models.rb

if $development
    DataMapper.setup(:default, "postgres://localhost/mistakesdb_default")
else
    DataMapper.setup(:default, "postgres://giberish:giberish@ec2-23-21-209-147.compute-1.amazonaws.com:5432/giberish")
end
DataMapper.finalize
if $development
    #DataMapper.auto_upgrade!
    DataMapper.auto_migrate!
else
    DataMapper.auto_upgrade!
    #DataMapper.auto_migrate!
end

###### required.rb ######
$development = File.exists?('/Users/adam')

##### Top of app.rb #####
require "./models.rb"
require "./required.rb"
require "sinatra"
require "sass"
require "sinatra/reloader" if $development
require "time-ago-in-words"
require "rest_client"
require "multimap"
4

1 に答える 1

1

開発モードの DataMapper は、missdb_default という名前のローカル PostgreSQL データベースに接続しようとしています。ローカルの postgres インストールがまったく実行されていないように見えるため、「接続が拒否されました」というエラーが表示されます。オペレーティング システムによっては、 http: //www.enterprisedb.com/ で簡単な postgres インストーラーを見つけることができる場合があります。

于 2012-11-13T19:52:38.153 に答える