【发布时间】:2014-06-25 10:04:29
【问题描述】:
我之前在 Stack Overflow 上查找过几个问题,但无法通过我的查询来识别其中的任何一个。我想用我的 RoR App 建立一个 mysql 数据库,但出现以下错误:-
=> Booting WEBrick
=> Rails 2.3.14 application starting on h t t p: / / localhost:3000
/usr/lib/ruby/1.8/yaml.rb:133:in `load': syntax error on line 6, col 2: ` host: localhost' (ArgumentError)
from /usr/lib/ruby/1.8/yaml.rb:133:in `load'
from /home/sumit/Sites/world_geography/config/../vendor/rails/railties/lib/initializer.rb:926:in `database_configuration'
from /home/sumit/Sites/world_geography/config/../vendor/rails/railties/lib/initializer.rb:437:in `initialize_database'
from /home/sumit/Sites/world_geography/config/../vendor/rails/railties/lib/initializer.rb:141:in `process'
from /home/sumit/Sites/world_geography/config/../vendor/rails/railties/lib/initializer.rb:113:in `send'
from /home/sumit/Sites/world_geography/config/../vendor/rails/railties/lib/initializer.rb:113:in `run'
from /home/sumit/Sites/world_geography/config/environment.rb:9
from /usr/lib/ruby/vendor_ruby/1.8/rubygems/custom_require.rb:36:in `gem_original_require'
from /usr/lib/ruby/vendor_ruby/1.8/rubygems/custom_require.rb:36:in `require'
from /usr/lib/ruby/vendor_ruby/active_support/dependencies.rb:182:in `require'
from /usr/lib/ruby/vendor_ruby/active_support/dependencies.rb:547:in `new_constants_in'
from /usr/lib/ruby/vendor_ruby/active_support/dependencies.rb:182:in `require'
from /home/sumit/Sites/world_geography/vendor/rails/railties/lib/commands/server.rb:84
from /usr/lib/ruby/vendor_ruby/1.8/rubygems/custom_require.rb:36:in `gem_original_require'
from /usr/lib/ruby/vendor_ruby/1.8/rubygems/custom_require.rb:36:in `require'
from script/server:3
//////////////////////////////////////////////////////////////////////////////////////
ruby -v :-> ruby 1.8.7
rails -v :-> 2.3.14
Also my database.yml file :->
development:
adapter: mysql
database: world_data_dev
username:root
host: local_host
port: 3000
pool: 5
timeout: 5000
# 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: world_data_test
username:root
host: localhost
port: 3000
pool: 5
timeout: 5000
production:
adapter: mysql
database: world_data_prod
username:root
host: localhost
port: 3000
pool: 5
timeout: 5000
Thanks!
【问题讨论】:
-
您使用的是哪个 gem?
-
嗨,我对 gem 不太了解,我只是浏览了一些视频教程并逐字逐句地实现它们。我需要为 mysql 安装一些 gem 吗?
-
你需要一个像 mysql2 这样的适配器 gem 来连接你的数据库和 rails 应用程序。
-
哦,好的,我先安装一下,一会儿告诉你
-
你好,我安装了mysql2 gem,仍然显示同样的错误!
标签: mysql ruby-on-rails yaml