2013-10-18 33 views
0

我有ROR版本4.0.0和ruby版本2.0.0。創建項目應用程序時,當我嘗試運行rails服務器它顯示我關於yml的錯誤文件。 屏幕看起來像這樣當我運行rails服務器它顯示有關database.yml的錯誤

C:\Sites\app>rails s 
=> Booting WEBrick 
=> Rails 4.0.0 application starting in development on 
=> Run `rails server -h` for more startup options 
=> Ctrl-C to shutdown server 
Exiting 
C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/railties-4.0.0/lib/rails/ap 
plication/configuration.rb:113:in `rescue in database_configuration': YAML synta 
x error occurred while parsing C:/Sites/app/config/database.yml. Please note tha 
t YAML must be consistently indented using spaces. Tabs are not allowed. Error: 
(<unknown>): could not find expected ':' while scanning a simple key at line 9 c 
olumn 3 (RuntimeError) 
     from C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/railties-4.0.0 
/lib/rails/application/configuration.rb:103:in `database_configuration' 
     from C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/activerecord-4 
.0.0/lib/active_record/railtie.rb:174:in `block (2 levels) in <class:Railtie>' 
     from C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/activesupport- 
4.0.0/lib/active_support/lazy_load_hooks.rb:38:in `instance_eval' 
     from C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/activesupport- 
4.0.0/lib/active_support/lazy_load_hooks.rb:38:in `execute_hook' 
     from C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/activesupport- 
4.0.0/lib/active_support/lazy_load_hooks.rb:28:in `block in on_load' 
     from C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/activesupport- 
4.0.0/lib/active_support/lazy_load_hooks.rb:27:in `each' 
     from C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/activesupport- 
4.0.0/lib/active_support/lazy_load_hooks.rb:27:in `on_load' 
     from C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/activerecord-4 
.0.0/lib/active_record/railtie.rb:173:in `block in <class:Railtie>' 
     from C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/railties-4.0.0 
/lib/rails/initializable.rb:30:in `instance_exec' 
     from C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/railties-4.0.0 
/lib/rails/initializable.rb:30:in `run' 
     from C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/railties-4.0.0 
/lib/rails/initializable.rb:55:in `block in run_initializers' 
     from C:/RailsInstaller/Ruby2.0.0/lib/ruby/2.0.0/tsort.rb:150:in `block i 
n tsort_each' 
     from C:/RailsInstaller/Ruby2.0.0/lib/ruby/2.0.0/tsort.rb:183:in `block (
2 levels) in each_strongly_connected_component' 
     from C:/RailsInstaller/Ruby2.0.0/lib/ruby/2.0.0/tsort.rb:219:in `each_st 
rongly_connected_component_from' 
     from C:/RailsInstaller/Ruby2.0.0/lib/ruby/2.0.0/tsort.rb:182:in `block i 
n each_strongly_connected_component' 
     from C:/RailsInstaller/Ruby2.0.0/lib/ruby/2.0.0/tsort.rb:180:in `each' 
     from C:/RailsInstaller/Ruby2.0.0/lib/ruby/2.0.0/tsort.rb:180:in `each_st 
rongly_connected_component' 
     from C:/RailsInstaller/Ruby2.0.0/lib/ruby/2.0.0/tsort.rb:148:in `tsort_e 
ach' 
     from C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/railties-4.0.0 
/lib/rails/initializable.rb:54:in `run_initializers' 

請幫我。

+1

顯示您database.yml你有縮進問題 – ahmet

+0

發佈你的'database.yml' – yamafontes

+1

你讀過什麼錯誤說espe在解析C:/Sites/app/config/database.yml時出現以下「YAML合成器x錯誤。請注意,YAML必須使用空格一致縮進。標籤是不允許的。錯誤:():找不到預期 ':' 而在第9行C「掃描簡單的按鍵 – Josnidhin

回答

2

您可以檢查你的YAML文件中使用缺少一個冒號線某種YAML Validator

這是您的有效YAML:

development: 
    adapter: postgresql 
    database: postgres 
    password: 191192 
    pool: 5 
    timeout: 5000 
    username: postgres 
production: 
    adapter: postgresql 
    database: postgres 
    pool: 5 
    timeout: 5000 
test: 
    adapter: postgresql 
    database: postgres 
    pool: 5 
    timeout: 5000 
0

我的猜測是你的標籤而不是database.yml中的空格。

快速修復在vim:

:%s/\t/ /g 
+0

如何做出改變 –

0

如果你看一看的痕跡,它會告訴你什麼是錯了你的database.yml文件。

"Please note that YAML must be consistently indented using spaces. Tabs are not allowed." 

"could not find expected ':' while scanning a simple key at line 9 column 3" 

因此,請確保您使用的空間,而不是標籤,看看你是否正在9.

+0

太感謝你了它的工作... –

0

我試圖在增加:

host:localhost 

原來我應該補充:

host: localhost 

一個空格後 「:」

希望這有助於

相關問題