未定义的方法' []' for nil:nilClass错误 - bundle exec rake db:migrate

时间:2014-05-18 10:39:55

标签: ruby-on-rails ruby ruby-on-rails-4 rake

运行时出现以下错误:

bundle exec rake db:migrate

我明白了:

  耙子流产了! StandardError:发生错误,此错误以及稍后发生   迁移已取消:

undefined method `[]' for nil:NilClass
Tasks: TOP => db:migrate
(See full trace by running task with --trace)

有什么想法来解决这个问题?这是一个带有一次迁移的新应用程序。

跟踪:

C:\Sites\check>bundle exec rake db:migrate --trace
** Invoke db:migrate (first_time)
** Invoke environment (first_time)
** Execute environment
** Invoke db:load_config (first_time)
** Execute db:load_config
** Execute db:migrate
==  Checklist: migrating ======================================================
-- create_table(:launch_checklists)
   -> 0.1650s
==  Checklist: migrated (0.1690s) =============================================

rake aborted!
StandardError: An error has occurred, this and all later migrations canceled:

undefined method `[]' for nil:NilClassC:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/
1.9.1/gems/activerecord-4.0.2/lib/active_record/attribute_methods/read.rb:86:in
`block in read_attribute'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activerecord-4.0.2/lib/acti
ve_record/attribute_methods/read.rb:84:in `fetch'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activerecord-4.0.2/lib/acti
ve_record/attribute_methods/read.rb:84:in `read_attribute'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activerecord-4.0.2/lib/acti
ve_record/attribute_methods.rb:243:in `block in attributes'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activerecord-4.0.2/lib/acti
ve_record/attribute_methods.rb:242:in `each'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activerecord-4.0.2/lib/acti
ve_record/attribute_methods.rb:242:in `each_with_object'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activerecord-4.0.2/lib/acti
ve_record/attribute_methods.rb:242:in `attributes'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activerecord-4.0.2/lib/acti
ve_record/attribute_methods/dirty.rb:84:in `keys_for_partial_write'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activerecord-4.0.2/lib/acti
ve_record/attribute_methods/dirty.rb:78:in `create_record'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activerecord-4.0.2/lib/acti
ve_record/callbacks.rb:306:in `block in create_record'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activesupport-4.0.2/lib/act
ive_support/callbacks.rb:373:in `_run__124220591__create__callbacks'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activesupport-4.0.2/lib/act
ive_support/callbacks.rb:80:in `run_callbacks'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activerecord-4.0.2/lib/acti
ve_record/callbacks.rb:306:in `create_record'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activerecord-4.0.2/lib/acti
ve_record/timestamp.rb:57:in `create_record'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activerecord-4.0.2/lib/acti
ve_record/persistence.rb:477:in `create_or_update'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activerecord-4.0.2/lib/acti
ve_record/callbacks.rb:302:in `block in create_or_update'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activesupport-4.0.2/lib/act
ive_support/callbacks.rb:373:in `_run__124220591__save__callbacks'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activesupport-4.0.2/lib/act
ive_support/callbacks.rb:80:in `run_callbacks'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activerecord-4.0.2/lib/acti
ve_record/callbacks.rb:302:in `create_or_update'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activerecord-4.0.2/lib/acti
ve_record/persistence.rb:128:in `save!'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activerecord-4.0.2/lib/acti
ve_record/validations.rb:57:in `save!'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activerecord-4.0.2/lib/acti
ve_record/attribute_methods/dirty.rb:41:in `save!'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activerecord-4.0.2/lib/acti
ve_record/transactions.rb:275:in `block in save!'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activerecord-4.0.2/lib/acti
ve_record/transactions.rb:326:in `block in with_transaction_returning_status'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activerecord-4.0.2/lib/acti
ve_record/connection_adapters/abstract/database_statements.rb:200:in `transactio
n'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activerecord-4.0.2/lib/acti
ve_record/transactions.rb:209:in `transaction'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activerecord-4.0.2/lib/acti
ve_record/transactions.rb:323:in `with_transaction_returning_status'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activerecord-4.0.2/lib/acti
ve_record/transactions.rb:275:in `save!'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/protected_attributes-1.0.3/
lib/active_record/mass_assignment_security/validations.rb:17:in `create!'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activerecord-4.0.2/lib/acti
ve_record/migration.rb:990:in `record_version_state_after_migrating'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activerecord-4.0.2/lib/acti
ve_record/migration.rb:960:in `block in execute_migration_in_transaction'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activerecord-4.0.2/lib/acti
ve_record/migration.rb:1005:in `block in ddl_transaction'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activerecord-4.0.2/lib/acti
ve_record/connection_adapters/abstract/database_statements.rb:202:in `block in t
ransaction'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activerecord-4.0.2/lib/acti
ve_record/connection_adapters/abstract/database_statements.rb:210:in `within_new
_transaction'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activerecord-4.0.2/lib/acti
ve_record/connection_adapters/abstract/database_statements.rb:202:in `transactio
n'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activerecord-4.0.2/lib/acti
ve_record/transactions.rb:209:in `transaction'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activerecord-4.0.2/lib/acti
ve_record/migration.rb:1005:in `ddl_transaction'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activerecord-4.0.2/lib/acti
ve_record/migration.rb:958:in `execute_migration_in_transaction'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activerecord-4.0.2/lib/acti
ve_record/migration.rb:920:in `block in migrate'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activerecord-4.0.2/lib/acti
ve_record/migration.rb:916:in `each'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activerecord-4.0.2/lib/acti
ve_record/migration.rb:916:in `migrate'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activerecord-4.0.2/lib/acti
ve_record/migration.rb:764:in `up'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activerecord-4.0.2/lib/acti
ve_record/migration.rb:742:in `migrate'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activerecord-4.0.2/lib/acti
ve_record/railties/databases.rake:42:in `block (2 levels) in <top (required)>'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rake-10.3.2/lib/rake/task.r
b:240:in `call'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rake-10.3.2/lib/rake/task.r
b:240:in `block in execute'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rake-10.3.2/lib/rake/task.r
b:235:in `each'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rake-10.3.2/lib/rake/task.r
b:235:in `execute'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rake-10.3.2/lib/rake/task.r
b:179:in `block in invoke_with_call_chain'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/1.9.1/monitor.rb:211:in `mon_synchronize'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rake-10.3.2/lib/rake/task.r
b:172:in `invoke_with_call_chain'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rake-10.3.2/lib/rake/task.r
b:165:in `invoke'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rake-10.3.2/lib/rake/applic
ation.rb:150:in `invoke_task'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rake-10.3.2/lib/rake/applic
ation.rb:106:in `block (2 levels) in top_level'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rake-10.3.2/lib/rake/applic
ation.rb:106:in `each'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rake-10.3.2/lib/rake/applic
ation.rb:106:in `block in top_level'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rake-10.3.2/lib/rake/applic
ation.rb:115:in `run_with_threads'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rake-10.3.2/lib/rake/applic
ation.rb:100:in `top_level'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rake-10.3.2/lib/rake/applic
ation.rb:78:in `block in run'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rake-10.3.2/lib/rake/applic
ation.rb:176:in `standard_exception_handling'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rake-10.3.2/lib/rake/applic
ation.rb:75:in `run'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rake-10.3.2/bin/rake:33:in
`<top (required)>'
C:/RailsInstaller/Ruby1.9.3/bin/rake:23:in `load'
C:/RailsInstaller/Ruby1.9.3/bin/rake:23:in `<main>'
Tasks: TOP => db:migrate

的database.yml

development:
  adapter: postgresql
  database: check_development 
  encoding: utf8
  pool: 5
  timeout: 5000
  host: localhost
  port: 5432
  username: postgres
  password: mypass

  test:
  adapter: postgresql
  database: check_test 
  encoding: utf8
  pool: 5
  timeout: 5000
  host: localhost
  port: 5432
  username: postgres
  password: mypass

production:
  adapter: postgresql
  database: check_production 
  encoding: utf8
  pool: 5
  timeout: 5000
  host: localhost
  port: 5432
  username: postgres
  password: mypass

0 个答案:

没有答案