Ruby on rails 解析C:/Users/vanesa/rails\u space/config/database.yml时发生YAML语法错误
在命令提示符中输入此代码时:Ruby on rails 解析C:/Users/vanesa/rails\u space/config/database.yml时发生YAML语法错误,ruby-on-rails,ruby,parsing,yaml,config,Ruby On Rails,Ruby,Parsing,Yaml,Config,在命令提示符中输入此代码时: rails g model User 以下是我在控制台中得到的信息: YAML syntax error occurred while parsing C:/Users/Vanessa/rails_space/config/database.yml. Please note that YAML must be consistently indented using spaces. Tabs are not allowed. Error:
rails g model User
以下是我在控制台中得到的信息:
YAML syntax error occurred while parsing
C:/Users/Vanessa/rails_space/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 7 column 1 (RuntimeError)
分析时发生YAML语法错误
C:/Users/vanesa/rails\u space/config/database.yml。请注意,YAML
必须使用空格一致地缩进。不允许使用选项卡。错误:
():在解析处的块映射时未找到所需的键
第7行第1列(运行时错误)
以下是我的config/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: sqlite3
pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
timeout: 5000
development:
adapter: mysql
database: rails_space_development
username: root
password: NothingToSeeHere
host: localhost
<<: *default
database: db/development.sqlite3
# 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
database: db/test.sqlite3
production:
<<: *default
database: db/production.sqlite3
#SQLite。支持3.8.0及以上版本。
#gem安装sqlite3
#
#确保在gem文件中定义了SQLite 3 gem
#gem'sqlite3'
#
默认值:&默认值
适配器:sqlite3
游泳池:
超时:5000
发展:
适配器:mysql
数据库:rails\u space\u开发
用户名:root
密码:NothingTosehere
主机:本地主机
看起来,在开发键下,对于适配器,您有一个间距错误。尝试将其更改为:
development:
adapter: mysql
适配器
前面的空格太多
YAML对于间距非常具体。正如您所发现的,即使是一个额外的空间也会抛出一个错误。您必须确保使用空格,而不是制表符。在开发键下,对于适配器,您似乎有一个空格错误。尝试将其更改为:
development:
adapter: mysql
适配器
前面的空格太多
YAML对于间距非常具体。正如您所发现的,即使是一个额外的空间也会抛出一个错误。您必须确保使用空格,而不是制表符。另外,在线上有很多YAML验证程序,以及大多数编辑器的插件,它们将在编写YAML时验证YAML。嘿,非常感谢,解决了我的问题。这是一个快速修复。谢谢,伙计。另外,在线上有很多YAML验证器,以及大多数编辑器的插件,它们可以在编写YAML时对其进行验证。嘿,非常感谢,解决了我的问题。这是一个快速修复。谢谢你,伙计。