您好,我正在尝试使用此链接创建一个刮板程序,但我在尝试创建一个db https://towardsdatascience.com/job-board-scraping-with-rails-872c432ed2c8时遇到了困难。
当我尝试在文件夹内部和外部创建rake db:create时,我得到了这个错误,我不确定为什么,非常感谢。我一直在密切关注链接,所以我有所有相同的文件,并确保一切都安装正确。
rake aborted!
ActiveRecord::DatabaseConfigurations::InvalidConfigurationError:
'{ default => }' is not a valid configuration. Expected '' to be a URL string or a Hash.这是我的database.yml文件
# SQLite. Versions 3.8.0 and up are supported.
# gem install sqlite3
#
# Ensure the SQLite 3 gem is defined in your Gemfile
# gem 'sqlite3'
#
default: &default
adapter: postgresql
pool: 5
timeout: 5000
development:
<<: *default
database: scraper_development
test:
<<: *default
database: scraper_test
production:
<<: *default
url: <%= ENV['DATABASE_URL'] %>
# Warning: The database defined as "test" will be erased and
# re-generated from your development database when you run "rake".
# Do not set this db to the same as development or production.提前感谢大家!
更新
谢谢你的指针,我把database.yml文件缩进了,但我觉得有个错误告诉我要去掉制表符。现在的新问题:
could not connect to server: No such file or directory
Is the server running locally and accepting connections on Unix domain socket "/tmp/.s.PGSQL.5432"?
Couldn't create 'scraper_development' database.
Please check your configuration.
rails aborted!
PG::ConnectionBad: could not connect to server: No such file or directory
Is the server running locally and accepting connections on Unix domain socket "/tmp/.s.PGSQL.5432"发布于 2020-10-27 02:09:39
该文件位于YAML format中。子项必须缩进。
default: &default
adapter: postgresql
pool: 5
timeout: 5000
development:
<<: *default
database: scraper_development发布于 2020-10-27 17:15:52
您可以在gem文件中添加“gem 'pg',‘YAML 0.18','< 2.0’”,并在>=文件中进行必要的设置。
https://stackoverflow.com/questions/64542482
复制相似问题