2011-12-10 4 views
0

私はフレックスとレールの使い方を説明していますが、データベースに関するいくつかの問題に直面しています。Rubys Yamlの問題

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 5.5

- 私を使用してスクリプトの実行に使用する

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

誰でも助けることができますか?

+0

わかりやすいかどうかわかりません。しかし、[mysql2](http://rubygems.org/gems/mysql2)gemは現在、Rails用MySQLアダプタとして推奨されています。 – jibiel

+0

あなたのシステムにmysql gemがあることを確認してください(ガイドラインについては、 'database.yml'の一番上のコメント部分を参照してください)、ymlファイルの行が正しくインデントされていることを確認してください。 – jibiel

+0

そして、plsはコードからパスワードを削除します。 –

答えて

2

RAILS_ENVdevelopmentである必要があります。まったく指定しないでください(デフォルトはdevelopment)。

環境では、データベースの名前ではありません、それはRailsの環境、一般developmentstage、またはproductionの名前です。変数はdatabase.ymlのいずれかの設定と揃う必要があります。

関連する問題