Rails问题用mysql创建一个新的脚手架

时间:2011-08-09 12:42:56

标签: ruby-on-rails ruby-on-rails-3

我试图用rails3和mysql5.5建立一个新的脚手架。我得到一个错误,无法解析YAML或其他什么,所以我按照this question的指导,但现在我收到此错误,我不明白为什么。

C:\projectname>rails generate scaffold Website name:string
invoke  active_record
path/to/lib/ruby/1.9.1/syck.rb:135:in `load': syntax error on line 15, col 2: host:     localhost' (ArgumentError)
    from path/to/lib/ruby/1.9.1/syck.rb:135:in `load'
    from path/to/railties-3.0.9/lib/rails/application/configuration.rb:88:in `database_configuration'
    from path/to/activerecord-3.0.9/lib/active_record/railtie.rb:58:in `block (2 levels) in<class:Railtie>'
    from path/to/activesupport-3.0.9/lib/active_support/lazy_load_hooks.rb:36:in `instance_eval'
    from path/to/activesupport-3.0.9/lib/active_support/lazy_load_hooks.rb:36:in `execute_hook'
    from path/to/activesupport-3.0.9/lib/active_support/lazy_load_hooks.rb:43:in `block in run_load_hooks'
    from path/to/activesupport-3.0.9/lib/active_support/lazy_load_hooks.rb:42:in `each'
    from path/to/activesupport-3.0.9/lib/active_support/lazy_load_hooks.rb:42:in `run_load_hooks'
    from path/to/activerecord-3.0.9/lib/active_record/base.rb:1909:in `<top (required)>'
    from path/to/railties-3.0.9/lib/rails/generators/named_base.rb:97:in `pluralize_table_names?'
    from path/to/railties-3.0.9/lib/rails/generators/named_base.rb:44:in `table_name'
    from path/to/activerecord-3.0.9/lib/rails/generators/active_record/model/model_generator.rb:16:in `create_migration_file'
    from path/to/thor-0.14.6/lib/thor/task.rb:22:in `run'
    from path/to/thor-0.14.6/lib/thor/invocation.rb:118:in `invoke_task'
    from path/to/thor-0.14.6/lib/thor/invocation.rb:124:in `block in invoke_all'
    from path/to/thor-0.14.6/lib/thor/invocation.rb:124:in `each'
    from path/to/thor-0.14.6/lib/thor/invocation.rb:124:in `map'
    from path/to/thor-0.14.6/lib/thor/invocation.rb:124:in `invoke_all'
    from path/to/thor-0.14.6/lib/thor/group.rb:226:in `dispatch'
    from path/to/thor-0.14.6/lib/thor/invocation.rb:109:in `invoke'
    from path/to/thor-0.14.6/lib/thor/group.rb:269:in `block in _invoke_for_class_method'
    from path/to/thor-0.14.6/lib/thor/shell.rb:74:in `with_padding'
    from path/to/thor-0.14.6/lib/thor/group.rb:258:in `_invoke_for_class_method'
    from path/to/thor-0.14.6/lib/thor/group.rb:150:in `_invoke_from_option_orm'
    from path/to/thor-0.14.6/lib/thor/task.rb:22:in `run'
    from path/to/thor-0.14.6/lib/thor/invocation.rb:118:in `invoke_task'
    from path/to/thor-0.14.6/lib/thor/invocation.rb:124:in `block in invoke_all'
    from path/to/thor-0.14.6/lib/thor/invocation.rb:124:in `each'
    from path/to/thor-0.14.6/lib/thor/invocation.rb:124:in `map'
    from path/to/thor-0.14.6/lib/thor/invocation.rb:124:in `invoke_all'
    from path/to/thor-0.14.6/lib/thor/group.rb:226:in `dispatch'
    from path/to/thor-0.14.6/lib/thor/base.rb:389:in `start'
    from path/to/railties-3.0.9/lib/rails/generators.rb:163:in `invoke'
    from path/to/railties-3.0.9/lib/rails/commands/generate.rb:10:in `<top (required)>'
    from path/to/activesupport-3.0.9/lib/active_support/dependencies.rb:239:in `require'
    from path/to/activesupport-3.0.9/lib/active_support/dependencies.rb:239:in `block in require'
    from path/to/activesupport-3.0.9/lib/active_support/dependencies.rb:225:in `block in load_dependency'
    from path/to/activesupport-3.0.9/lib/active_support/dependencies.rb:596:in `new_constants_in'
    from path/to/activesupport-3.0.9/lib/active_support/dependencies.rb:225:in `load_dependency'
    from path/to/activesupport-3.0.9/lib/active_support/dependencies.rb:239:in `require'
    from path/to/railties-3.0.9/lib/rails/commands.rb:17:in `<top (required)>'
    from script/rails:6:in `require'
    from script/rails:6:in `<main>'

任何帮助解决这个问题都将受到赞赏。

1 个答案:

答案 0 :(得分:2)

您是否阅读过错误消息?看起来你在数据库配置文件中缺少冒号,昏迷或类似的东西。它靠近“host:localhost”