2014-08-28 65 views
0

我的PostgreSQL安裝到計算機上,它似乎在電腦前工作的很好,但是當我運行此:Ruby on Rails的壞URI

$ bundle exec rspec spec/requests/static_pages_spec.rb 

它給此錯誤消息

$ bundle exec rspec spec/requests/static_pages_spec.rbL is deprecated, please use Fiddle:/Ruby200-x64/lib/ruby/2.0.0/uri/common.rb:176:in `split': bad URI(is not URI?) 
: postgres:///zacks-pc\zack holbrook (URI::InvalidURIError) 
    from c:/Ruby200-x64/lib/ruby/2.0.0/uri/common.rb:211:in `parse' 
    from c:/Ruby200-x64/lib/ruby/2.0.0/uri/common.rb:747:in `parse' 
    from c:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/activerecord-4.0.8/lib/actie_record/connection_adapters/connection_specification.rb:69:in `connection_url_o_hash' 
    from c:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/activerecord-4.0.8/lib/actie_record/connection_adapters/connection_specification.rb:41:in `block in resolv_string_connection' 
    from c:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/activerecord-4.0.8/lib/actie_record/connection_adapters/connection_specification.rb:40:in `fetch' 
    from c:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/activerecord-4.0.8/lib/actie_record/connection_adapters/connection_specification.rb:40:in `resolve_string_onnection' 
    from c:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/activerecord-4.0.8/lib/actie_record/connection_adapters/connection_specification.rb:32:in `spec' 
    from c:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/activerecord-4.0.8/lib/actie_record/connection_handling.rb:39:in `establish_connection' 
    from c:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/activerecord-4.0.8/lib/actie_record/railtie.rb:176:in `block (2 levels) in <class:Railtie>' 
    from c:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/activesupport-4.0.8/lib/actve_support/lazy_load_hooks.rb:38:in `instance_eval' 
    from c:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/activesupport-4.0.8/lib/actve_support/lazy_load_hooks.rb:38:in `execute_hook' 
    from c:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/activesupport-4.0.8/lib/actve_support/lazy_load_hooks.rb:45:in `block in run_load_hooks' 
    from c:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/activesupport-4.0.8/lib/actve_support/lazy_load_hooks.rb:44:in `each' 
    from c:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/activesupport-4.0.8/lib/actve_support/lazy_load_hooks.rb:44:in `run_load_hooks' 
    from c:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/activerecord-4.0.8/lib/actie_record/base.rb:322:in `<module:ActiveRecord>' 
    from c:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/activerecord-4.0.8/lib/actie_record/base.rb:22:in `<top (required)>' 
    from c:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/rspec-rails-2.13.1/lib/rspe/rails/extensions/active_record/base.rb:19:in `<module:Extensions>' 
    from c:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/rspec-rails-2.13.1/lib/rspe/rails/extensions/active_record/base.rb:4:in `<module:Rails>' 
    from c:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/rspec-rails-2.13.1/lib/rspe/rails/extensions/active_record/base.rb:2:in `<module:RSpec>' 
    from c:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/rspec-rails-2.13.1/lib/rspe/rails/extensions/active_record/base.rb:1:in `<top (required)>' 
    from c:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/activesupport-4.0.8/lib/actve_support/dependencies.rb:229:in `require' 
    from c:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/activesupport-4.0.8/lib/actve_support/dependencies.rb:229:in `block in require' 
    from c:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/activesupport-4.0.8/lib/actve_support/dependencies.rb:214:in `load_dependency' 
    from c:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/activesupport-4.0.8/lib/actve_support/dependencies.rb:229:in `require' 
    from c:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/rspec-rails-2.13.1/lib/rspe/rails/extensions.rb:1:in `<top (required)>' 
    from c:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/activesupport-4.0.8/lib/actve_support/dependencies.rb:229:in `require' 
    from c:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/activesupport-4.0.8/lib/actve_support/dependencies.rb:229:in `block in require' 
    from c:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/activesupport-4.0.8/lib/actve_support/dependencies.rb:214:in `load_dependency' 
    from c:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/activesupport-4.0.8/lib/actve_support/dependencies.rb:229:in `require' 
    from c:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/rspec-rails-2.13.1/lib/rspe/rails.rb:9:in `<top (required)>' 
    from c:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/activesupport-4.0.8/lib/actve_support/dependencies.rb:229:in `require' 
    from c:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/activesupport-4.0.8/lib/actve_support/dependencies.rb:229:in `block in require' 
    from c:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/activesupport-4.0.8/lib/actve_support/dependencies.rb:214:in `load_dependency' 
    from c:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/activesupport-4.0.8/lib/actve_support/dependencies.rb:229:in `require' 
    from c:/Sites/rails_projects/sample_app/spec/spec_helper.rb:4:in `<top (equired)>' 
    from c:/Sites/rails_projects/sample_app/spec/requests/static_pages_spec.b:1:in `require' 
    from c:/Sites/rails_projects/sample_app/spec/requests/static_pages_spec.b:1:in `<top (required)>' 
    from c:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/rspec-core-2.13.1/lib/rspec/core/configuration.rb:819:in `load' 
    from c:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/rspec-core-2.13.1/lib/rspec/core/configuration.rb:819:in `block in load_spec_files' 
    from c:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/rspec-core-2.13.1/lib/rspec/core/configuration.rb:819:in `each' 
    from c:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/rspec-core-2.13.1/lib/rspec/core/configuration.rb:819:in `load_spec_files' 
    from c:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/rspec-core-2.13.1/lib/rspec/core/command_line.rb:22:in `run' 
    from c:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/rspec-core-2.13.1/lib/rspec/core/runner.rb:80:in `run' 
    from c:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/rspec-core-2.13.1/lib/rspec/core/runner.rb:17:in `block in autorun' 

什麼是URI,我需要改變它嗎? 我正在使用Windows,並且是Ruby on Rails的新手,任何幫助將不勝感激,謝謝! 該網站是在Github上:https://github.com/ioniz4tion/sample_app/tree/postgre

的database.yml

development: 
    adapter: postgresql 
    encoding: unicode 
    host: localhost 
    database: cnh_development 
    pool: 5 
    username: cnh 
    password: my_password 

test: 
    adapter: postgresql 
    encoding: unicode 
    host: localhost 
    database: cnh_test 
    pool: 5 
    username: cnh 
    password: my_password 

production: 
    adapter: postgresql 
    encoding: unicode 
    host: localhost 
    database: cnh_production 
    pool: 5 
    username: cnh 
    password: my_password 
+0

您可以發佈您spec_helper和static_pages_spec文件? – Martin 2014-08-28 18:58:43

+0

我在github上的網站,https://github.com/ioniz4tion/sample_app/tree/postgre將工作? – Zack 2014-08-28 19:03:00

+0

你能發佈database.yml文件嗎 – 2014-08-28 19:20:09

回答

0

它看起來像你的Postgres的配置有問題。在消息您提供:

postgres:///zacks-pc\zack holbrook 

這看起來像那種URL的Postgres的使用來識別數據庫,但向前和向後斜線的搭配(/ VS)看起來怪我。看看你的數據庫配置,它很可能來自那裏。

0

在你database.yml文件,嘗試一些類似這樣的,如果你的工作在你的本地文件

login: &login 
    adapter: postgresql 
    host: localhost 
    username: postgres 
    password: yourpassword! 
    pool: 5 
    encoding: unicode 


development: 
    database: dbname 
    <<: *login 

test: 
    database: dbname 
    <<: *login 

production: 
    database: dbname 
    <<: *login