【发布时间】:2016-01-24 06:25:49
【问题描述】:
我整天都在玩空间,但终其一生都无法让我的 Heroku 应用程序迁移数据库。我不断得到
rake aborted!
YAML syntax error occurred while parsing /app/config/database.yml. Please note that YAML must be consistently indented using spaces. Tabs are not allowed. Error: (<unknown>): did not find expected key while parsing a block mapping at line 62 column 3
除了我已经通过三个不同的验证器运行我的 YAML 文件并且他们都被告知它们是“有效的”之外,这一切都很好,而且很花哨。
这是已编辑有问题的 YAML
# PostgreSQL. Versions 8.2 and up are supported.
#
# Install the pg driver:
# gem install pg
# On OS X with Homebrew:
# gem install pg -- --with-pg-config=/usr/local/bin/pg_config
# On OS X with MacPorts:
# gem install pg -- --with-pg-config=/opt/local/lib/postgresql84/bin/pg_config
# On Windows:
# gem install pg
# Choose the win32 build.
# Install PostgreSQL and put its /bin directory on your path.
#
# Configure Using Gemfile
# gem 'pg'
#
default: &default
adapter: postgresql
encoding: unicode
pool: 5
development:
<<: *default
database: coder-app_title
username: postgres
password: 123456
host: localhost
username: personal_username
password: personal_password
# 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 [[<< This is line 62.]]
database: coder-add_title_test
username: postgres
password: 123456
host: localhost
# As with config/secrets.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 as a unix environment variable when you boot
# the app. Read http://guides.rubyonrails.org/configuring.html#configuring-a-database
# for a full rundown on how to provide these environment variables in a
# production deployment.
#
# On Heroku and other platform providers, you may have a full connection URL
# available as an environment variable. For example:
#
# DATABASE_URL="postgres://myuser:mypass@localhost/somedatabase"
#
# You can use this database configuration with:
#
production:
url: <%= ENV['DATABASE_URL'] %>
#
production:
【问题讨论】:
-
第 62 行不是您标记的行,而是文件中的最后一行。
-
删除文件末尾的两个
production:部分。你不需要它们。 Heroku 在提交后挂钩中将生产数据库设置写入database.yml。 -
您应该考虑使用环境变量“DATABASE_URL”而不是推送数据库配置。
标签: ruby-on-rails ruby heroku yaml