当我尝试在名为expertiza的这个开源项目(链接:https://github.com/expertiza/expertiza)上运行rake db:migrate时,收到此错误消息。完整信息如下所示。我认为问题可能是环境设置有问题。有没有办法在不更改代码的情况下修复此错误?
错误讯息:
payup.db
这是menu.rb中报告的rake aborted!
StandardError: An error has occurred, all later migrations canceled:
undefined method `empty?' for nil:NilClass
/home/maxinghua/expertiza/app/models/menu.rb:81:in `initialize'
/home/maxinghua/expertiza/app/models/role.rb:87:in `new'
/home/maxinghua/expertiza/app/models/role.rb:87:in `rebuild_menu'
/home/maxinghua/expertiza/app/models/role.rb:73:in `block in rebuild_cache'
/home/maxinghua/.rvm/gems/ruby-2.2.4/gems/activerecord-4.2.6/lib/active_record/relation/batches.rb:51:in `block (2 levels) in find_each'
/home/maxinghua/.rvm/gems/ruby-2.2.4/gems/activerecord-4.2.6/lib/active_record/relation/batches.rb:51:in `each'
/home/maxinghua/.rvm/gems/ruby-2.2.4/gems/activerecord-4.2.6/lib/active_record/relation/batches.rb:51:in `block in find_each'
/home/maxinghua/.rvm/gems/ruby-2.2.4/gems/activerecord-4.2.6/lib/active_record/relation/batches.rb:124:in `find_in_batches'
/home/maxinghua/.rvm/gems/ruby-2.2.4/gems/activerecord-4.2.6/lib/active_record/relation/batches.rb:50:in `find_each'
/home/maxinghua/.rvm/gems/ruby-2.2.4/gems/activerecord-4.2.6/lib/active_record/querying.rb:9:in `find_each'
/home/maxinghua/expertiza/app/models/role.rb:67:in `rebuild_cache'
/home/maxinghua/expertiza/db/migrate/002_initialize_custom.rb:184:in `up'
/home/maxinghua/.rvm/gems/ruby-2.2.4/gems/activerecord-4.2.6/lib/active_record/migration.rb:571:in `up'
/home/maxinghua/.rvm/gems/ruby-2.2.4/gems/activerecord-4.2.6/lib/active_record/migration.rb:611:in `exec_migration'
/home/maxinghua/.rvm/gems/ruby-2.2.4/gems/activerecord-4.2.6/lib/active_record/migration.rb:592:in `block (2 levels) in migrate'
/home/maxinghua/.rvm/gems/ruby-2.2.4/gems/activerecord-4.2.6/lib/active_record/migration.rb:591:in `block in migrate'
/home/maxinghua/.rvm/gems/ruby-2.2.4/gems/activerecord-4.2.6/lib/active_record/connection_adapters/abstract/connection_pool.rb:292:in `with_connection'
/home/maxinghua/.rvm/gems/ruby-2.2.4/gems/activerecord-4.2.6/lib/active_record/migration.rb:590:in `migrate'
/home/maxinghua/.rvm/gems/ruby-2.2.4/gems/activerecord-4.2.6/lib/active_record/migration.rb:768:in `migrate'
/home/maxinghua/.rvm/gems/ruby-2.2.4/gems/activerecord-4.2.6/lib/active_record/migration.rb:998:in `block in execute_migration_in_transaction'
/home/maxinghua/.rvm/gems/ruby-2.2.4/gems/activerecord-4.2.6/lib/active_record/migration.rb:1046:in `ddl_transaction'
/home/maxinghua/.rvm/gems/ruby-2.2.4/gems/activerecord-4.2.6/lib/active_record/migration.rb:997:in `execute_migration_in_transaction'
/home/maxinghua/.rvm/gems/ruby-2.2.4/gems/activerecord-4.2.6/lib/active_record/migration.rb:959:in `block in migrate'
/home/maxinghua/.rvm/gems/ruby-2.2.4/gems/activerecord-4.2.6/lib/active_record/migration.rb:955:in `each'
/home/maxinghua/.rvm/gems/ruby-2.2.4/gems/activerecord-4.2.6/lib/active_record/migration.rb:955:in `migrate'
/home/maxinghua/.rvm/gems/ruby-2.2.4/gems/activerecord-4.2.6/lib/active_record/migration.rb:823:in `up'
/home/maxinghua/.rvm/gems/ruby-2.2.4/gems/activerecord-4.2.6/lib/active_record/migration.rb:801:in `migrate'
/home/maxinghua/.rvm/gems/ruby-2.2.4/gems/activerecord-4.2.6/lib/active_record/tasks/database_tasks.rb:137:in `migrate'
/home/maxinghua/.rvm/gems/ruby-2.2.4/gems/activerecord-4.2.6/lib/active_record/railties/databases.rake:44:in `block (2 levels) in <top (required)>'
/home/maxinghua/.rvm/gems/ruby-2.2.4/gems/airbrake-5.5.0/lib/airbrake/rake/task_ext.rb:19:in `execute'
/home/maxinghua/.rvm/gems/ruby-2.2.4/gems/rake-11.2.2/exe/rake:27:in `<top (required)>'
/home/maxinghua/.rvm/gems/ruby-2.2.4/bin/ruby_executable_hooks:15:in `eval'
/home/maxinghua/.rvm/gems/ruby-2.2.4/bin/ruby_executable_hooks:15:in `<main>'
NoMethodError: undefined method `empty?' for nil:NilClass
/home/maxinghua/expertiza/app/models/menu.rb:81:in `initialize'
/home/maxinghua/expertiza/app/models/role.rb:87:in `new'
/home/maxinghua/expertiza/app/models/role.rb:87:in `rebuild_menu'
/home/maxinghua/expertiza/app/models/role.rb:73:in `block in rebuild_cache'
/home/maxinghua/.rvm/gems/ruby-2.2.4/gems/activerecord-4.2.6/lib/active_record/relation/batches.rb:51:in `block (2 levels) in find_each'
/home/maxinghua/.rvm/gems/ruby-2.2.4/gems/activerecord-4.2.6/lib/active_record/relation/batches.rb:51:in `each'
/home/maxinghua/.rvm/gems/ruby-2.2.4/gems/activerecord-4.2.6/lib/active_record/relation/batches.rb:51:in `block in find_each'
/home/maxinghua/.rvm/gems/ruby-2.2.4/gems/activerecord-4.2.6/lib/active_record/relation/batches.rb:124:in `find_in_batches'
/home/maxinghua/.rvm/gems/ruby-2.2.4/gems/activerecord-4.2.6/lib/active_record/relation/batches.rb:50:in `find_each'
/home/maxinghua/.rvm/gems/ruby-2.2.4/gems/activerecord-4.2.6/lib/active_record/querying.rb:9:in `find_each'
/home/maxinghua/expertiza/app/models/role.rb:67:in `rebuild_cache'
/home/maxinghua/expertiza/db/migrate/002_initialize_custom.rb:184:in `up'
/home/maxinghua/.rvm/gems/ruby-2.2.4/gems/activerecord-4.2.6/lib/active_record/migration.rb:571:in `up'
/home/maxinghua/.rvm/gems/ruby-2.2.4/gems/activerecord-4.2.6/lib/active_record/migration.rb:611:in `exec_migration'
/home/maxinghua/.rvm/gems/ruby-2.2.4/gems/activerecord-4.2.6/lib/active_record/migration.rb:592:in `block (2 levels) in migrate'
/home/maxinghua/.rvm/gems/ruby-2.2.4/gems/activerecord-4.2.6/lib/active_record/migration.rb:591:in `block in migrate'
/home/maxinghua/.rvm/gems/ruby-2.2.4/gems/activerecord-4.2.6/lib/active_record/connection_adapters/abstract/connection_pool.rb:292:in `with_connection'
/home/maxinghua/.rvm/gems/ruby-2.2.4/gems/activerecord-4.2.6/lib/active_record/migration.rb:590:in `migrate'
/home/maxinghua/.rvm/gems/ruby-2.2.4/gems/activerecord-4.2.6/lib/active_record/migration.rb:768:in `migrate'
/home/maxinghua/.rvm/gems/ruby-2.2.4/gems/activerecord-4.2.6/lib/active_record/migration.rb:998:in `block in execute_migration_in_transaction'
/home/maxinghua/.rvm/gems/ruby-2.2.4/gems/activerecord-4.2.6/lib/active_record/migration.rb:1046:in `ddl_transaction'
/home/maxinghua/.rvm/gems/ruby-2.2.4/gems/activerecord-4.2.6/lib/active_record/migration.rb:997:in `execute_migration_in_transaction'
/home/maxinghua/.rvm/gems/ruby-2.2.4/gems/activerecord-4.2.6/lib/active_record/migration.rb:959:in `block in migrate'
/home/maxinghua/.rvm/gems/ruby-2.2.4/gems/activerecord-4.2.6/lib/active_record/migration.rb:955:in `each'
/home/maxinghua/.rvm/gems/ruby-2.2.4/gems/activerecord-4.2.6/lib/active_record/migration.rb:955:in `migrate'
/home/maxinghua/.rvm/gems/ruby-2.2.4/gems/activerecord-4.2.6/lib/active_record/migration.rb:823:in `up'
/home/maxinghua/.rvm/gems/ruby-2.2.4/gems/activerecord-4.2.6/lib/active_record/migration.rb:801:in `migrate'
/home/maxinghua/.rvm/gems/ruby-2.2.4/gems/activerecord-4.2.6/lib/active_record/tasks/database_tasks.rb:137:in `migrate'
/home/maxinghua/.rvm/gems/ruby-2.2.4/gems/activerecord-4.2.6/lib/active_record/railties/databases.rake:44:in `block (2 levels) in <top (required)>'
/home/maxinghua/.rvm/gems/ruby-2.2.4/gems/airbrake-5.5.0/lib/airbrake/rake/task_ext.rb:19:in `execute'
/home/maxinghua/.rvm/gems/ruby-2.2.4/gems/rake-11.2.2/exe/rake:27:in `<top (required)>'
/home/maxinghua/.rvm/gems/ruby-2.2.4/bin/ruby_executable_hooks:15:in `eval'
/home/maxinghua/.rvm/gems/ruby-2.2.4/bin/ruby_executable_hooks:15:in `<main>'
Tasks: TOP => db:migrate
(See full trace by running task with --trace)
方法代码:81:empty?
:
initialize