警告钩子before_worker_boot失败,出现异常 (URI::InvalidURIError) 错误的 URI(不是 URI?): "DATABASE_URL=" postgres://



我正试图为某人的项目提供rails服务器,用于学习目的。但是在使用postgresql进行设置时会出现此错误,请提供帮助。

rails aborted!
URI::InvalidURIError: bad URI(is not URI?): "DATABASE_URL="postgres://resume_builder""
/usr/lib/ruby/2.7.0/uri/rfc3986_parser.rb:67:in `split'
/usr/lib/ruby/2.7.0/uri/rfc3986_parser.rb:73:in `parse'

这是堆栈跟踪下面是database.yml文件

default: &default
adapter: postgresql
encoding: unicode
# For details on connection pooling, see Rails configuration guide
# https://guides.rubyonrails.org/configuring.html#database-pooling
pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
development:
<<: *default
database: resume_builder
url: "postgres://localhost/somedatabase"
# The specified database role being used to connect to postgres.
# To create additional roles in postgres see `$ createuser --help`.
# When left blank, postgres will use the default role. This is
# the same name as the operating system user running Rails.
username: resume_builder
# The password associated with the postgres role (username).
password: test
# Connect on a TCP socket. Omitted by default since the client uses a
# domain socket that doesn't need configuration. Windows does not have
# domain sockets, so uncomment these lines.
host: localhost
# The TCP port the server listens on. Defaults to 5432.
# If your server runs on a different port number, change accordingly.
port: 5432
# Schema search path. The server defaults to $user,public
#schema_search_path: myapp,sharedapp,public
# Minimum log levels, in increasing order:
#   debug5, debug4, debug3, debug2, debug1,
#   log, notice, warning, error, fatal, and panic
# Defaults to warning.
#min_messages: notice
# 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.
test:
# <<: *default
# As with config/credentials.yml, you never want to store sensitive information,
# like your database password, in your source code. If your source code is
# ever seen by anyone, they now have access to your database.
#
# Instead, provide the password or a full connection URL as an environment
# variable when you boot the app. For example:
#
DATABASE_URL="postgres://resume_builder"
#
# If the connection URL is provided in the special DATABASE_URL environment
# variable, Rails will automatically merge its configuration values on top of
# the values provided in this file. Alternatively, you can specify a connection
# URL environment variable explicitly:
#
#   production:
#     url: <%= ENV['MY_APP_DATABASE_URL'] %>
#
# Read https://guides.rubyonrails.org/configuring.html#configuring-a-database
# for a full overview on how database connection configuration can be specified.
#
production:
<<: *default
url: postgres://resume_builder

7055]警告钩子before_worker_boot失败,出现异常(URI::InvalidURIError(错误的URI(不是URI吗?(:"DATABASE_ URL=";postgres://resume_builder"quot;[7052]警告钩子before_worker_boot失败,出现异常(URI::InvalidURIError(错误的URI(不是URI吗?(:"DATABASE_ URL=";postgres://resume_builder"quot;出现在rails服务器上的错误

YAML文件不能有=,因为在YAML的规范中它是而不是

用url连接数据库有标准的方法。

URL分为以下信息适配器、用户名、密码、域、数据库名称

例如,

postgresql://ecldev@localhost/post_development

这里,

  1. postgres=适配器
  2. ecldev=用户名
  3. localhost=域
  4. post_development=数据库名称

注意-@是强制性的。

在您的情况下,url是";postgres://resume_builder"。是没有用户名,域。

示例图像

更新

只需更改

DATABASE_URL="postgres://resume_builder"DATABASE_URL: "postgres://resume_builder"

最新更新