Rubys Yaml的问题

时间:2011-12-10 13:20:04

标签: mysql ruby yaml

我试图跟随abook解释如何使用flex和rails,但我面临着数据库的一些问题。我也在使用MySql 5.5

我遇到了以下问题:

C:\flexible_rails\current\pomodo>call rake db:migrate RAILS_ENV=pomodo_development  --trace
** Invoke db:migrate (first_time)
** Invoke environment (first_time)
** Execute environment
** Invoke db:load_config (first_time)
** Invoke rails_env (first_time)
** Execute rails_env
** Execute db:load_config
rake aborted!
pomodo_development database is not configured
C:/Ruby192/lib/ruby/gems/1.9.1/gems/activerecord-3.1.3/lib/active_record/connect
ion_adapters/abstract/connection_specification.rb:62:in `establish_connection'
C:/Ruby192/lib/ruby/gems/1.9.1/gems/activerecord-3.1.3/lib/active_record/connect
ion_adapters/abstract/connection_specification.rb:55:in `establish_connection'
C:/Ruby192/lib/ruby/gems/1.9.1/gems/activerecord-3.1.3/lib/active_record/railtie
.rb:69:in `block (2 levels) in <class:Railtie>'
C:/Ruby192/lib/ruby/gems/1.9.1/gems/activesupport-3.1.3/lib/active_support/lazy_
load_hooks.rb:36:in `instance_eval'
C:/Ruby192/lib/ruby/gems/1.9.1/gems/activesupport-3.1.3/lib/active_support/lazy_
load_hooks.rb:36:in `execute_hook'
C:/Ruby192/lib/ruby/gems/1.9.1/gems/activesupport-3.1.3/lib/active_support/lazy_
load_hooks.rb:43:in `block in run_load_hooks'
C:/Ruby192/lib/ruby/gems/1.9.1/gems/activesupport-3.1.3/lib/active_support/lazy_
load_hooks.rb:42:in `each'
C:/Ruby192/lib/ruby/gems/1.9.1/gems/activesupport-3.1.3/lib/active_support/lazy_
load_hooks.rb:42:in `run_load_hooks'
C:/Ruby192/lib/ruby/gems/1.9.1/gems/activerecord-3.1.3/lib/active_record/base.rb
:2190:in `<top (required)>'
C:/Ruby192/lib/ruby/gems/1.9.1/gems/activerecord-3.1.3/lib/active_record/railtie
s/databases.rake:6:in `block (2 levels) in <top (required)>'
C:/Ruby192/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:205:in `call'
C:/Ruby192/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:205:in `block
in execute'
C:/Ruby192/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:200:in `each'
C:/Ruby192/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:200:in `execut
e'
C:/Ruby192/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:158:in `block
in invoke_with_call_chain'
C:/Ruby192/lib/ruby/1.9.1/monitor.rb:201:in `mon_synchronize'
C:/Ruby192/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:151:in `invoke
_with_call_chain'
C:/Ruby192/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:176:in `block
in invoke_prerequisites'
C:/Ruby192/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:174:in `each'
C:/Ruby192/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:174:in `invoke
_prerequisites'
C:/Ruby192/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:157:in `block
in invoke_with_call_chain'
C:/Ruby192/lib/ruby/1.9.1/monitor.rb:201:in `mon_synchronize'
C:/Ruby192/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:151:in `invoke
_with_call_chain'
C:/Ruby192/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:144:in `invoke
'
C:/Ruby192/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:116:in
`invoke_task'
C:/Ruby192/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:94:in `
block (2 levels) in top_level'
C:/Ruby192/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:94:in `
each'
C:/Ruby192/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:94:in `
block in top_level'
C:/Ruby192/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:133:in
`standard_exception_handling'
C:/Ruby192/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:88:in `
top_level'
C:/Ruby192/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:66:in `
block in run'
C:/Ruby192/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:133:in
`standard_exception_handling'
C:/Ruby192/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:63:in `
run'
C:/Ruby192/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/bin/rake:33:in `<top (required)
>'
C:/Ruby192/bin/rake:19:in `load'
C:/Ruby192/bin/rake:19:in `<main>'
Tasks: TOP => db:migrate => db:load_config`

我的数据库yml:

# Install the MySQL driver:
# gem install mysql
# On MacOS X:
# sudo gem install mysql -- --with-mysql-dir=/usr/local/mysql
# 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
  encoding: utf8
  database: pomodo_development
  username: pomodo
  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
  encoding: utf8
  database: pomodo_test
  username: pomodo
  password: ****
  host: localhost

production:
  adapter: mysql
  encoding: utf8
  database: pomodo_production
  username: pomodo
  password: ***
  host: localhost`

create.sql

drop database if exists pomodo_development;
create database pomodo_development;
drop database if exists pomodo_test;
create database pomodo_test;
drop database if exists pomodo_production;
create database pomodo_production;
GRANT ALL PRIVILEGES ON pomodo_development.* TO 'pomodo'@'localhost'
IDENTIFIED BY '*****' WITH GRANT OPTION;
GRANT ALL PRIVILEGES ON pomodo_test.* TO 'pomodo'@'localhost'
IDENTIFIED BY '*****' WITH GRANT OPTION;
GRANT ALL PRIVILEGES ON pomodo_production.* TO 'pomodo'@'localhost'
IDENTIFIED BY '*****' WITH GRANT OPTION;`

我用来运行脚本的蝙蝠

mysql -h localhost -u root -p <db\create.sql
call rake db:migrate RAILS_ENV=pomodo_development  --trace`

任何人都可以帮忙???

1 个答案:

答案 0 :(得分:2)

RAILS_ENV应该是development,或者根本没有(development是默认值)。

环境不是数据库的名称,它是Rails环境的名称,通常是developmentstageproduction。变量应与database.yml中的一个配置对齐。