Rails控制台错误

时间:2011-03-03 05:59:20

标签: ruby-on-rails ruby console yaml

我一直试图让我的rails堆栈设置时间最长,到目前为止我已经能够运行一切,但是当我尝试运行rails控制台时出现此错误:

C:/Ruby192/lib/ruby/1.9.1/psych.rb:148:in `parse': couldn't parse YAML at line 8 column 0 (Psych::SyntaxError)
  from C:/Ruby192/lib/ruby/1.9.1/psych.rb:148:in `parse_stream'
  from C:/Ruby192/lib/ruby/1.9.1/psych.rb:119:in `parse'
  from C:/Ruby192/lib/ruby/1.9.1/psych.rb:106:in `load'
  from C:/Ruby192/lib/ruby/gems/1.9.1/gems/railties-3.0.5.rc1/lib/rails/application/configuration.rb:88:in `database_configuration'
  from C:/Ruby192/lib/ruby/gems/1.9.1/gems/activerecord-3.0.5.rc1/lib/active_record/railtie.rb:58:in `block (2 levels) in <class:Railtie>'
  from C:/Ruby192/lib/ruby/gems/1.9.1/gems/activesupport-3.0.5.rc1/lib/active_support/lazy_load_hooks.rb:36:in `instance_eval'
  from C:/Ruby192/lib/ruby/gems/1.9.1/gems/activesupport-3.0.5.rc1/lib/active_support/lazy_load_hooks.rb:36:in `execute_hook'
  from C:/Ruby192/lib/ruby/gems/1.9.1/gems/activesupport-3.0.5.rc1/lib/active_support/lazy_load_hooks.rb:43:in `block in run_load_hooks'
  from C:/Ruby192/lib/ruby/gems/1.9.1/gems/activesupport-3.0.5.rc1/lib/active_support/lazy_load_hooks.rb:42:in `each'
  from C:/Ruby192/lib/ruby/gems/1.9.1/gems/activesupport-3.0.5.rc1/lib/active_support/lazy_load_hooks.rb:42:in `run_load_hooks'
  from C:/Ruby192/lib/ruby/gems/1.9.1/gems/activerecord-3.0.5.rc1/lib/active_record/base.rb:1900:in `<top (required)>'
  from C:/Ruby192/lib/ruby/gems/1.9.1/gems/activerecord-3.0.5.rc1/lib/active_record/railtie.rb:32:in `block in <class:Railtie>'
  from C:/Ruby192/lib/ruby/gems/1.9.1/gems/railties-3.0.5.rc1/lib/rails/railtie.rb:180:in `call'
  from C:/Ruby192/lib/ruby/gems/1.9.1/gems/railties-3.0.5.rc1/lib/rails/railtie.rb:180:in `each'
  from C:/Ruby192/lib/ruby/gems/1.9.1/gems/railties-3.0.5.rc1/lib/rails/railtie.rb:180:in `load_console'
  from C:/Ruby192/lib/ruby/gems/1.9.1/gems/railties-3.0.5.rc1/lib/rails/application.rb:154:in `block in load_console'
  from C:/Ruby192/lib/ruby/gems/1.9.1/gems/railties-3.0.5.rc1/lib/rails/application/railties.rb:11:in `each'
  from C:/Ruby192/lib/ruby/gems/1.9.1/gems/railties-3.0.5.rc1/lib/rails/application/railties.rb:11:in `all'
  from C:/Ruby192/lib/ruby/gems/1.9.1/gems/railties-3.0.5.rc1/lib/rails/application.rb:154:in `load_console'
  from C:/Ruby192/lib/ruby/gems/1.9.1/gems/railties-3.0.5.rc1/lib/rails/commands/console.rb:26:in `start'
  from C:/Ruby192/lib/ruby/gems/1.9.1/gems/railties-3.0.5.rc1/lib/rails/commands/console.rb:8:in `start'
  from C:/Ruby192/lib/ruby/gems/1.9.1/gems/railties-3.0.5.rc1/lib/rails/commands.rb:23:in `<top (required)>'
  from script/rails:6:in `require'
  from script/rails:6:in `<main>'

我在网上看到了各种修复,但他们并没有最终解决问题。只是想知道是否有其他人有同样的问题或知道如何解决它。感谢。

Database.yml:
# SQLite version 3.x
# gem install sqlite3
development:
  adapter: mysql
  database: shovell_development
  pool: 5
  timeout: 5000
    username: root
    password: randompassword12
    host: localhost

# 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: mysql
  database: shovell_test
  pool: 5
  timeout: 5000
    username: root
    password: randompassword12
    host: localhost

production:
  adapter: mysql
  database: shovell_production
  pool: 5
  timeout: 5000
    username: root
    password: randompassword12
    host: localhost

3 个答案:

答案 0 :(得分:4)

问题在于database.yml文件的格式。 timeout: 5000下的行不应该被标记,即:

development:
  adapter: mysql
  database: shovell_development
  pool: 5
  timeout: 5000
  username: root
  password: randompassword12
  host: localhost

答案 1 :(得分:2)

usernamepasswordhost缩进太多。它们应该与每个环境名称下的其他参数缩进相同。

答案 2 :(得分:1)

只需删除用户名,密码和主机左侧的空格,使其对齐并尝试。