学习《应用Rails进行敏捷Web开发》时遇到购物车的问题

学习《应用Rails进行敏捷Web开发》时遇到购物车的问题

K:\Work>cd depot

K:\Work\depot>ruby script/generate scaffold Product Admin
我在执行这一句的时候出现了以下错误!请问一下为什么以及怎么解决啊?谢谢


J:/编程软件/php?name=Ruby" onclick="tagshow(event)" class="t_tag">Ruby/lib/ruby/1.8/yaml.rb:133:in `load': syntax error on line 18, co
l 2: ` host: 127.0.0.1' (ArgumentError)
   from J:/编程软件/Ruby/lib/ruby/1.8/yaml.rb:133:in `load'
   from J:/编程软件/Ruby/lib/ruby/gems/1.8/gems/rails-1.2.3/lib/initializer
.rb:523:in `database_configuration'
   from J:/编程软件/Ruby/lib/ruby/gems/1.8/gems/rails-1.2.3/lib/initializer
.rb:228:in `initialize_database'
   from J:/编程软件/Ruby/lib/ruby/gems/1.8/gems/rails-1.2.3/lib/initializer
.rb:88:in `process'
   from J:/编程软件/Ruby/lib/ruby/gems/1.8/gems/rails-1.2.3/lib/initializer
.rb:43:in `send'
   from J:/编程软件/Ruby/lib/ruby/gems/1.8/gems/rails-1.2.3/lib/initializer
.rb:43:in `run'
   from ./script/../config/../config/environment.rb:13
   from J:/编程软件/Ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:
27:in `gem_original_require'
   from J:/编程软件/Ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:
27:in `require'
   from J:/编程软件/Ruby/lib/ruby/gems/1.8/gems/rails-1.2.3/lib/commands/ge
nerate.rb:1
   from J:/编程软件/Ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:
27:in `gem_original_require'
   from J:/编程软件/Ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:
27:in `require'
   from script/generate:3
通常的数据库连接的问题,检查下database.yml文件。
你看看这个有问题么?谢谢


# MySQL (default setup). Versions 4.1 and 5.0 are recommended.
#
# Install the MySQL driver:
# gem install mysql
# On MacOS X:
# gem install mysql -- --include=/usr/local/lib
# On Windows:
# gem install mysql
#   Choose the win32 build.
#   Install MySQL and put its /bin directory on your path.
#
# And be sure to use new-style password hashing:
# http://dev.mysql.com/doc/refman/5.0/en/old-client.html
development:
 adapter: mysql
 database: depot_development
 username: root
 password:
 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: depot_test
 username:root
 password:
host: localhost

production:
 adapter: mysql
 database: depot_production
 username: root
 password:
 host: localhost
密码有空格,删掉空格
K:\>cd Work

K:\Work>cd depot

K:\Work\depot>ruby script/generate scaffold Product Admin
这次是这个错误勒!是不是没有这个数据库的意思啊?但是我建了的勒

J:/编程软件/Ruby/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/active_record/co
nnection_adapters/abstract/connection_specification.rb:204:in `establish_connect
ion': adapter:mysql database:depot_development username:root password:
host:localhost database is not configured (ActiveRecord::AdapterNotS
pecified)
   from J:/编程软件/Ruby/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/act
ive_record/connection_adapters/abstract/connection_specification.rb:202:in `esta
blish_connection'
   from J:/编程软件/Ruby/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/act
ive_record/connection_adapters/abstract/connection_specification.rb:195:in `esta
blish_connection'
   from J:/编程软件/Ruby/lib/ruby/gems/1.8/gems/rails-1.2.3/lib/initializer
.rb:229:in `initialize_database'
   from J:/编程软件/Ruby/lib/ruby/gems/1.8/gems/rails-1.2.3/lib/initializer
.rb:88:in `process'
   from J:/编程软件/Ruby/lib/ruby/gems/1.8/gems/rails-1.2.3/lib/initializer
.rb:43:in `send'
   from J:/编程软件/Ruby/lib/ruby/gems/1.8/gems/rails-1.2.3/lib/initializer
.rb:43:in `run'
   from ./script/../config/../config/environment.rb:13
   from J:/编程软件/Ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:
27:in `gem_original_require'
   from J:/编程软件/Ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:
27:in `require'
   from J:/编程软件/Ruby/lib/ruby/gems/1.8/gems/rails-1.2.3/lib/commands/ge
nerate.rb:1
   from J:/编程软件/Ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:
27:in `gem_original_require'
   from J:/编程软件/Ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:
27:in `require'
   from script/generate:3
和Bless4me一样的错。
不一样吧
是不是与中文路径有关系啊?
看不出这个错误
不会吧!还认中文路径问题啊?老火勒!
发现勒!并不是中文问题!database.yml需要这样写,例如
development:
 adapter:*mysql
 database:*depot_development
 username:*root
 password:*你的密码
 host:*localhost

test:
 adapter:*mysql
 database:*depot_test
 username:*root
 password:*你的密码
 host:*localhost

production:
 adapter:*mysql
 database:*depot_production
 username:*root
 password:*你的密码
 host:*localhost

注意:每个子节点下面必须要有一个空格,就是上面的*代表空格
希望大家都能够学得更好!