我已将postgresql安装到计算机上,它似乎对计算机工作正常,但是当我运行它时:
$ 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 :(得分:0)
看起来你的postgres配置有问题。在您提供的消息中:
postgres:///zacks-pc\zack holbrook
这看起来像Postgres用于识别数据库的URL,但前向和后向斜杠(/ vs)的混合看起来很奇怪。看看你的数据库配置,很可能来自那里。
答案 1 :(得分: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