我无法使用Ruby on Rails通过提示创建PostgreSQL数据库

时间:2014-01-05 23:57:04

标签: ruby-on-rails ruby windows postgresql

Hello Guys我正在尝试研究Ruby On Rails,但我无法继续阅读一本书 巴西作家。

我一步一步走(A,B,C,D,见下文)并正确安装POSTGRESQL

A)我正确安装了Ruby。

C:\rails>ruby -v
ruby 1.9.3p429 (2013-05-15) [i386-mingw32]

B)我正确安装了Gems。

C:\rails>gem -v
2.1.11

C)我正确安装了所有宝石RAILS。

***************************** GEM INSTALADADAS ***********

gem install rubygems-update-1.3.1.gem

gem install rake-0.8.4.gem

gem install activesupport-1.4.4.gem


gem install activesupport-2.3.2.gem 

gem install activerecord-1.15.6.gem  

gem install activerecord-2.3.2.gem

gem install actionpack-1.13.6.gem REM ***

gem install actionpack-2.3.2.gem 

gem install actionmailer-2.3.2.gem

gem install actionwebservice-1.2.6.gem

gem install activeresource-2.3.2.gem  

gem install rails-2.3.2.gem 

gem install postgres-pr-0.6.1.gem 

D)Rails安装正确。

C:\rails>rails -v
Rails 2.3.2

运行以下命令

cd projetos 

rails --database postgresql projeto01

模板创建了完美的网站。

运行命令时

cd\projetos\projeto01 
rake db:create 

出现以下错误:

错误1

C:\Projetos\projeto01>rake db:create
uninitialized constant PostgresPR::Connection::UNIXSocket
C:/ruby/lib/ruby/gems/1.9.1/gems/activesupport-2.3.2/lib/active_support/dependen
cies.rb:105:in `rescue in const_missing'
C:/ruby/lib/ruby/gems/1.9.1/gems/activesupport-2.3.2/lib/active_support/dependen
cies.rb:94:in `const_missing'
C:/ruby/lib/ruby/gems/1.9.1/gems/postgres-pr-0.6.1/lib/postgres-pr/connection.rb
:167:in `establish_connection'
C:/ruby/lib/ruby/gems/1.9.1/gems/postgres-pr-0.6.1/lib/postgres-pr/connection.rb
:51:in `initialize'
C:/ruby/lib/ruby/gems/1.9.1/gems/postgres-pr-0.6.1/lib/postgres-pr/postgres-comp
at.rb:23:in `new'
C:/ruby/lib/ruby/gems/1.9.1/gems/postgres-pr-0.6.1/lib/postgres-pr/postgres-comp
at.rb:23:in `initialize'
C:/ruby/lib/ruby/gems/1.9.1/gems/activerecord-2.3.2/lib/active_record/connection
_adapters/postgresql_adapter.rb:916:in `new'
C:/ruby/lib/ruby/gems/1.9.1/gems/activerecord-2.3.2/lib/active_record/connection
_adapters/postgresql_adapter.rb:916:in `connect'
C:/ruby/lib/ruby/gems/1.9.1/gems/activerecord-2.3.2/lib/active_record/connection
_adapters/postgresql_adapter.rb:210:in `initialize'
C:/ruby/lib/ruby/gems/1.9.1/gems/activerecord-2.3.2/lib/active_record/connection
_adapters/postgresql_adapter.rb:37:in `new'
C:/ruby/lib/ruby/gems/1.9.1/gems/activerecord-2.3.2/lib/active_record/connection
_adapters/postgresql_adapter.rb:37:in `postgresql_connection'
C:/ruby/lib/ruby/gems/1.9.1/gems/activerecord-2.3.2/lib/active_record/connection
_adapters/abstract/connection_pool.rb:223:in `new_connection'
C:/ruby/lib/ruby/gems/1.9.1/gems/activerecord-2.3.2/lib/active_record/connection
_adapters/abstract/connection_pool.rb:245:in `checkout_new_connection'
C:/ruby/lib/ruby/gems/1.9.1/gems/activerecord-2.3.2/lib/active_record/connection
_adapters/abstract/connection_pool.rb:188:in `block (2 levels) in checkout'
C:/ruby/lib/ruby/gems/1.9.1/gems/activerecord-2.3.2/lib/active_record/connection
_adapters/abstract/connection_pool.rb:184:in `loop'
C:/ruby/lib/ruby/gems/1.9.1/gems/activerecord-2.3.2/lib/active_record/connection
_adapters/abstract/connection_pool.rb:184:in `block in checkout'
C:/ruby/lib/ruby/1.9.1/monitor.rb:211:in `mon_synchronize'
C:/ruby/lib/ruby/gems/1.9.1/gems/activerecord-2.3.2/lib/active_record/connection
_adapters/abstract/connection_pool.rb:183:in `checkout'
C:/ruby/lib/ruby/gems/1.9.1/gems/activerecord-2.3.2/lib/active_record/connection
_adapters/abstract/connection_pool.rb:98:in `connection'
C:/ruby/lib/ruby/gems/1.9.1/gems/activerecord-2.3.2/lib/active_record/connection
_adapters/abstract/connection_pool.rb:326:in `retrieve_connection'
C:/ruby/lib/ruby/gems/1.9.1/gems/activerecord-2.3.2/lib/active_record/connection
_adapters/abstract/connection_specification.rb:123:in `retrieve_connection'
C:/ruby/lib/ruby/gems/1.9.1/gems/activerecord-2.3.2/lib/active_record/connection
_adapters/abstract/connection_specification.rb:115:in `connection'
C:/ruby/lib/ruby/gems/1.9.1/gems/rails-2.3.2/lib/tasks/databases.rake:70:in `res
cue in create_database'
C:/ruby/lib/ruby/gems/1.9.1/gems/rails-2.3.2/lib/tasks/databases.rake:35:in `cre
ate_database'
C:/ruby/lib/ruby/gems/1.9.1/gems/rails-2.3.2/lib/tasks/databases.rake:31:in `blo
ck (2 levels) in <top (required)>'
C:/ruby/lib/ruby/gems/1.9.1/gems/rake-10.1.1/lib/rake/task.rb:236:in `call'
C:/ruby/lib/ruby/gems/1.9.1/gems/rake-10.1.1/lib/rake/task.rb:236:in `block in e
xecute'
C:/ruby/lib/ruby/gems/1.9.1/gems/rake-10.1.1/lib/rake/task.rb:231:in `each'
C:/ruby/lib/ruby/gems/1.9.1/gems/rake-10.1.1/lib/rake/task.rb:231:in `execute'
C:/ruby/lib/ruby/gems/1.9.1/gems/rake-10.1.1/lib/rake/task.rb:175:in `block in i
nvoke_with_call_chain'
C:/ruby/lib/ruby/1.9.1/monitor.rb:211:in `mon_synchronize'
C:/ruby/lib/ruby/gems/1.9.1/gems/rake-10.1.1/lib/rake/task.rb:168:in `invoke_wit
h_call_chain'
C:/ruby/lib/ruby/gems/1.9.1/gems/rake-10.1.1/lib/rake/task.rb:161:in `invoke'
C:/ruby/lib/ruby/gems/1.9.1/gems/rake-10.1.1/lib/rake/application.rb:149:in `inv
oke_task'
C:/ruby/lib/ruby/gems/1.9.1/gems/rake-10.1.1/lib/rake/application.rb:106:in `blo
ck (2 levels) in top_level'
C:/ruby/lib/ruby/gems/1.9.1/gems/rake-10.1.1/lib/rake/application.rb:106:in `eac
h'
C:/ruby/lib/ruby/gems/1.9.1/gems/rake-10.1.1/lib/rake/application.rb:106:in `blo
ck in top_level'
C:/ruby/lib/ruby/gems/1.9.1/gems/rake-10.1.1/lib/rake/application.rb:115:in `run
_with_threads'
C:/ruby/lib/ruby/gems/1.9.1/gems/rake-10.1.1/lib/rake/application.rb:100:in `top
_level'
C:/ruby/lib/ruby/gems/1.9.1/gems/rake-10.1.1/lib/rake/application.rb:78:in `bloc
k in run'
C:/ruby/lib/ruby/gems/1.9.1/gems/rake-10.1.1/lib/rake/application.rb:165:in `sta
ndard_exception_handling'
C:/ruby/lib/ruby/gems/1.9.1/gems/rake-10.1.1/lib/rake/application.rb:75:in `run'

C:/ruby/lib/ruby/gems/1.9.1/gems/rake-10.1.1/bin/rake:33:in `<top (required)>'
C:/ruby/bin/rake:23:in `load'
C:/ruby/bin/rake:23:in `<main>'
Couldn't create database for {"adapter"=>"postgresql", "encoding"=>"UTF-8", "dat
abase"=>"projeto01_development", "pool"=>5, "username"=>"exercicio_livro", "pass
word"=>"rails"}

C:\Projetos\projeto01>rake db:create
uninitialized constant PostgresPR::Connection::UNIXSocket
C:/ruby/lib/ruby/gems/1.9.1/gems/activesupport-2.3.2/lib/active_support/dependen
cies.rb:105:in `rescue in const_missing'
C:/ruby/lib/ruby/gems/1.9.1/gems/activesupport-2.3.2/lib/active_support/dependen
cies.rb:94:in `const_missing'
C:/ruby/lib/ruby/gems/1.9.1/gems/postgres-pr-0.6.1/lib/postgres-pr/connection.rb
:167:in `establish_connection'
C:/ruby/lib/ruby/gems/1.9.1/gems/postgres-pr-0.6.1/lib/postgres-pr/connection.rb
:51:in `initialize'
C:/ruby/lib/ruby/gems/1.9.1/gems/postgres-pr-0.6.1/lib/postgres-pr/postgres-comp
at.rb:23:in `new'
C:/ruby/lib/ruby/gems/1.9.1/gems/postgres-pr-0.6.1/lib/postgres-pr/postgres-comp
at.rb:23:in `initialize'
C:/ruby/lib/ruby/gems/1.9.1/gems/activerecord-2.3.2/lib/active_record/connection
_adapters/postgresql_adapter.rb:916:in `new'
C:/ruby/lib/ruby/gems/1.9.1/gems/activerecord-2.3.2/lib/active_record/connection
_adapters/postgresql_adapter.rb:916:in `connect'
C:/ruby/lib/ruby/gems/1.9.1/gems/activerecord-2.3.2/lib/active_record/connection
_adapters/postgresql_adapter.rb:210:in `initialize'
C:/ruby/lib/ruby/gems/1.9.1/gems/activerecord-2.3.2/lib/active_record/connection
_adapters/postgresql_adapter.rb:37:in `new'
C:/ruby/lib/ruby/gems/1.9.1/gems/activerecord-2.3.2/lib/active_record/connection
_adapters/postgresql_adapter.rb:37:in `postgresql_connection'
C:/ruby/lib/ruby/gems/1.9.1/gems/activerecord-2.3.2/lib/active_record/connection
_adapters/abstract/connection_pool.rb:223:in `new_connection'
C:/ruby/lib/ruby/gems/1.9.1/gems/activerecord-2.3.2/lib/active_record/connection
_adapters/abstract/connection_pool.rb:245:in `checkout_new_connection'
C:/ruby/lib/ruby/gems/1.9.1/gems/activerecord-2.3.2/lib/active_record/connection
_adapters/abstract/connection_pool.rb:188:in `block (2 levels) in checkout'
C:/ruby/lib/ruby/gems/1.9.1/gems/activerecord-2.3.2/lib/active_record/connection
_adapters/abstract/connection_pool.rb:184:in `loop'
C:/ruby/lib/ruby/gems/1.9.1/gems/activerecord-2.3.2/lib/active_record/connection
_adapters/abstract/connection_pool.rb:184:in `block in checkout'
C:/ruby/lib/ruby/1.9.1/monitor.rb:211:in `mon_synchronize'
C:/ruby/lib/ruby/gems/1.9.1/gems/activerecord-2.3.2/lib/active_record/connection
_adapters/abstract/connection_pool.rb:183:in `checkout'
C:/ruby/lib/ruby/gems/1.9.1/gems/activerecord-2.3.2/lib/active_record/connection
_adapters/abstract/connection_pool.rb:98:in `connection'
C:/ruby/lib/ruby/gems/1.9.1/gems/activerecord-2.3.2/lib/active_record/connection
_adapters/abstract/connection_pool.rb:326:in `retrieve_connection'
C:/ruby/lib/ruby/gems/1.9.1/gems/activerecord-2.3.2/lib/active_record/connection
_adapters/abstract/connection_specification.rb:123:in `retrieve_connection'
C:/ruby/lib/ruby/gems/1.9.1/gems/activerecord-2.3.2/lib/active_record/connection
_adapters/abstract/connection_specification.rb:115:in `connection'
C:/ruby/lib/ruby/gems/1.9.1/gems/rails-2.3.2/lib/tasks/databases.rake:70:in `res
cue in create_database'
C:/ruby/lib/ruby/gems/1.9.1/gems/rails-2.3.2/lib/tasks/databases.rake:35:in `cre
ate_database'
C:/ruby/lib/ruby/gems/1.9.1/gems/rails-2.3.2/lib/tasks/databases.rake:31:in `blo
ck (2 levels) in <top (required)>'
C:/ruby/lib/ruby/gems/1.9.1/gems/rake-10.1.1/lib/rake/task.rb:236:in `call'
C:/ruby/lib/ruby/gems/1.9.1/gems/rake-10.1.1/lib/rake/task.rb:236:in `block in e
xecute'
C:/ruby/lib/ruby/gems/1.9.1/gems/rake-10.1.1/lib/rake/task.rb:231:in `each'
C:/ruby/lib/ruby/gems/1.9.1/gems/rake-10.1.1/lib/rake/task.rb:231:in `execute'
C:/ruby/lib/ruby/gems/1.9.1/gems/rake-10.1.1/lib/rake/task.rb:175:in `block in i
nvoke_with_call_chain'
C:/ruby/lib/ruby/1.9.1/monitor.rb:211:in `mon_synchronize'
C:/ruby/lib/ruby/gems/1.9.1/gems/rake-10.1.1/lib/rake/task.rb:168:in `invoke_wit
h_call_chain'
C:/ruby/lib/ruby/gems/1.9.1/gems/rake-10.1.1/lib/rake/task.rb:161:in `invoke'
C:/ruby/lib/ruby/gems/1.9.1/gems/rake-10.1.1/lib/rake/application.rb:149:in `inv
oke_task'
C:/ruby/lib/ruby/gems/1.9.1/gems/rake-10.1.1/lib/rake/application.rb:106:in `blo
ck (2 levels) in top_level'
C:/ruby/lib/ruby/gems/1.9.1/gems/rake-10.1.1/lib/rake/application.rb:106:in `eac
h'
C:/ruby/lib/ruby/gems/1.9.1/gems/rake-10.1.1/lib/rake/application.rb:106:in `blo
ck in top_level'
C:/ruby/lib/ruby/gems/1.9.1/gems/rake-10.1.1/lib/rake/application.rb:115:in `run
_with_threads'
C:/ruby/lib/ruby/gems/1.9.1/gems/rake-10.1.1/lib/rake/application.rb:100:in `top
_level'
C:/ruby/lib/ruby/gems/1.9.1/gems/rake-10.1.1/lib/rake/application.rb:78:in `bloc
k in run'
C:/ruby/lib/ruby/gems/1.9.1/gems/rake-10.1.1/lib/rake/application.rb:165:in `sta
ndard_exception_handling'
C:/ruby/lib/ruby/gems/1.9.1/gems/rake-10.1.1/lib/rake/application.rb:75:in `run'

C:/ruby/lib/ruby/gems/1.9.1/gems/rake-10.1.1/bin/rake:33:in `<top (required)>'
C:/ruby/bin/rake:23:in `load'
C:/ruby/bin/rake:23:in `<main>'
Couldn't create database for {"adapter"=>"postgresql", "encoding"=>"UTF-8", "dat
abase"=>"projeto01_development", "pool"=>5, "username"=>"exercicio_livro", "pass
word"=>"rails"}

C:\Projetos\projeto01

错误2

C:\Projetos\projeto01> ruby script/server
C:/ruby/lib/ruby/site_ruby/1.9.1/rubygems/core_ext/kernel_require.rb:55:in `requ
ire': cannot load such file -- script/../config/boot (LoadError)
        from C:/ruby/lib/ruby/site_ruby/1.9.1/rubygems/core_ext/kernel_require.r
b:55:in `require'
        from script/server:2:in `<main>'

1 个答案:

答案 0 :(得分:1)

你的Gemfile中有postgres-pr个gem,据我所知,Rails不再支持它,而是使用pg gem。