您好我正在尝试将数据库添加到我的rails应用程序中。我使用sqlite3创建了一个名为proto_development的数据库,但是当我去使用rake db:create命令时,我收到以下错误
ROOT\first_app>rake db:create --trace
** Invoke db:create (first_time)
** Invoke db:load_config (first_time)
** Invoke rails_env (first_time)
** Execute rails_env
** Execute db:load_config
rake aborted!
(<unknown>): couldn't parse YAML at line 9 column 12
C:/Ruby193/lib/ruby/1.9.1/psych.rb:154:in `parse'
C:/Ruby193/lib/ruby/1.9.1/psych.rb:154:in `parse_stream'
C:/Ruby193/lib/ruby/1.9.1/psych.rb:125:in `parse'
C:/Ruby193/lib/ruby/1.9.1/psych.rb:112:in `load'
ROOT/first_app/sqlite3-ruby/ruby/1.9.1/gems/railties-3.1.0/lib/rails/application/configuration.rb:
100:in `database_configuration'
ROOT/first_app/sqlite3-ruby/ruby/1.9.1/gems/activerecord-3.1.0/lib/active_record/railties/database
s.rake:6:in `block (2 levels) in <top (required)>'
C:/Ruby193/lib/ruby/1.9.1/rake/task.rb:205:in `call'
C:/Ruby193/lib/ruby/1.9.1/rake/task.rb:205:in `block in execute'
C:/Ruby193/lib/ruby/1.9.1/rake/task.rb:200:in `each'
C:/Ruby193/lib/ruby/1.9.1/rake/task.rb:200:in `execute'
C:/Ruby193/lib/ruby/1.9.1/rake/task.rb:158:in `block in invoke_with_call_chain'
C:/Ruby193/lib/ruby/1.9.1/monitor.rb:211:in `mon_synchronize'
C:/Ruby193/lib/ruby/1.9.1/rake/task.rb:151:in `invoke_with_call_chain'
C:/Ruby193/lib/ruby/1.9.1/rake/task.rb:176:in `block in invoke_prerequisites'
C:/Ruby193/lib/ruby/1.9.1/rake/task.rb:174:in `each'
C:/Ruby193/lib/ruby/1.9.1/rake/task.rb:174:in `invoke_prerequisites'
C:/Ruby193/lib/ruby/1.9.1/rake/task.rb:157:in `block in invoke_with_call_chain'
C:/Ruby193/lib/ruby/1.9.1/monitor.rb:211:in `mon_synchronize'
C:/Ruby193/lib/ruby/1.9.1/rake/task.rb:151:in `invoke_with_call_chain'
C:/Ruby193/lib/ruby/1.9.1/rake/task.rb:144:in `invoke'
C:/Ruby193/lib/ruby/1.9.1/rake/application.rb:116:in `invoke_task'
C:/Ruby193/lib/ruby/1.9.1/rake/application.rb:94:in `block (2 levels) in top_level'
C:/Ruby193/lib/ruby/1.9.1/rake/application.rb:94:in `each'
C:/Ruby193/lib/ruby/1.9.1/rake/application.rb:94:in `block in top_level'
C:/Ruby193/lib/ruby/1.9.1/rake/application.rb:133:in `standard_exception_handling'
C:/Ruby193/lib/ruby/1.9.1/rake/application.rb:88:in `top_level'
C:/Ruby193/lib/ruby/1.9.1/rake/application.rb:66:in `block in run'
C:/Ruby193/lib/ruby/1.9.1/rake/application.rb:133:in `standard_exception_handling'
C:/Ruby193/lib/ruby/1.9.1/rake/application.rb:63:in `run'
C:/Ruby193/bin/rake:32:in `<main>'
Tasks: TOP => db:create => db:load_config
以下是我的YAML文件: #SQLite版本3.x. #gem install sqlite3 #确保在Gemfile中定义了SQLite 3 gem #gem'sqlite3'
development:
adapter: sqlite3
database: db/proto_development.sqlite3
pool: 5
timeout: 5000
username: root
password: "p"
# 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:
adapter: sqlite3
database: db/test.sqlite3
pool: 5
timeout: 5000
username: root
password: "p"
production:
adapter: sqlite3
database: db/production.sqlite3
pool: 5
timeout: 5000
username: root
password: "p"
非常感谢您提供的任何帮助。
由于
答案 0 :(得分:2)
确保您的database.yml文件中的密码是一个字符串,而不是所有数字。例如,321会引发错误,b321会起作用。这可能有用。