我正在尝试从 redmine 1.0 迁移到 redmine 2.3,但在运行 db:migrate 时出现错误。
sudo rake db:migrate RAILS_ENV=production --trace
(in /opt/redmine-2.3)
/var/lib/gems/1.8/gems/rake-10.0.4/lib/rake/file_utils.rb:9: warning: already initialized constant RUBY
/var/lib/gems/1.8/gems/rake-10.0.4/lib/rake/file_utils.rb:86: warning: already initialized constant LN_SUPPORTED
** Invoke db:migrate (first_time)
** Invoke environment (first_time)
** Execute environment
** Invoke db:load_config (first_time)
** Execute db:load_config
** Execute db:migrate
== BuildProjectsTree: migrating ==============================================
rake aborted!
An error has occurred, all later migrations canceled:
undefined method `inherit_members_changed?' for #<Project:0x7f82e2dad038>
/var/lib/gems/1.8/gems/activemodel-3.2.13/lib/active_model/attribute_methods.rb:407:in `method_missing'
/var/lib/gems/1.8/gems/activerecord-3.2.13/lib/active_record/attribute_methods.rb:149:in `method_missing'
/opt/redmine-2.3/app/models/project.rb:85:in `_callback_after_748'
/var/lib/gems/1.8/gems/activesupport-3.2.13/lib/active_support/callbacks.rb:460:in `_run__1269722363__save__4__callbacks'
/var/lib/gems/1.8/gems/activesupport-3.2.13/lib/active_support/callbacks.rb:405:in `send'
/var/lib/gems/1.8/gems/activesupport-3.2.13/lib/active_support/callbacks.rb:405:in `__run_callback'
/var/lib/gems/1.8/gems/activesupport-3.2.13/lib/active_support/callbacks.rb:385:in `_run_save_callbacks'
/var/lib/gems/1.8/gems/activesupport-3.2.13/lib/active_support/callbacks.rb:81:in `send'
/var/lib/gems/1.8/gems/activesupport-3.2.13/lib/active_support/callbacks.rb:81:in `run_callbacks'
/var/lib/gems/1.8/gems/activerecord-3.2.13/lib/active_record/callbacks.rb:264:in `create_or_update'
/var/lib/gems/1.8/gems/activerecord-3.2.13/lib/active_record/persistence.rb:104:in `save!'
/var/lib/gems/1.8/gems/activerecord-3.2.13/lib/active_record/validations.rb:56:in `save!'
/var/lib/gems/1.8/gems/activerecord-3.2.13/lib/active_record/attribute_methods/dirty.rb:33:in `save!'
/var/lib/gems/1.8/gems/activerecord-3.2.13/lib/active_record/transactions.rb:264:in `save!'
/var/lib/gems/1.8/gems/activerecord-3.2.13/lib/active_record/transactions.rb:313:in `with_transaction_returning_status'
/var/lib/gems/1.8/gems/activerecord-3.2.13/lib/active_record/connection_adapters/abstract/database_statements.rb:192:in `transaction'
/var/lib/gems/1.8/gems/activerecord-3.2.13/lib/active_record/transactions.rb:208:in `transaction'
/var/lib/gems/1.8/gems/activerecord-3.2.13/lib/active_record/transactions.rb:311:in `with_transaction_returning_status'
/var/lib/gems/1.8/gems/activerecord-3.2.13/lib/active_record/transactions.rb:264:in `save!'
/opt/redmine-2.3/lib/plugins/awesome_nested_set/lib/awesome_nested_set/awesome_nested_set.rb:185:in `rebuild!'
/opt/redmine-2.3/lib/plugins/awesome_nested_set/lib/awesome_nested_set/awesome_nested_set.rb:192:in `call'
/opt/redmine-2.3/lib/plugins/awesome_nested_set/lib/awesome_nested_set/awesome_nested_set.rb:192:in `rebuild!'
/var/lib/gems/1.8/gems/activerecord-3.2.13/lib/active_record/relation/delegation.rb:6:in `each'
/var/lib/gems/1.8/gems/activerecord-3.2.13/lib/active_record/relation/delegation.rb:6:in `__send__'
/var/lib/gems/1.8/gems/activerecord-3.2.13/lib/active_record/relation/delegation.rb:6:in `each'
/opt/redmine-2.3/lib/plugins/awesome_nested_set/lib/awesome_nested_set/awesome_nested_set.rb:189:in `rebuild!'
/opt/redmine-2.3/app/models/project.rb:416:in `rebuild_tree!'
/var/lib/gems/1.8/gems/activerecord-3.2.13/lib/active_record/connection_adapters/abstract/database_statements.rb:192:in `transaction'
/var/lib/gems/1.8/gems/activerecord-3.2.13/lib/active_record/transactions.rb:208:in `transaction'
/opt/redmine-2.3/app/models/project.rb:414:in `rebuild_tree!'
/opt/redmine-2.3/db/migrate/105_build_projects_tree.rb:3:in `up'
/var/lib/gems/1.8/gems/activerecord-3.2.13/lib/active_record/migration.rb:370:in `up'
/var/lib/gems/1.8/gems/activerecord-3.2.13/lib/active_record/migration.rb:410:in `send'
/var/lib/gems/1.8/gems/activerecord-3.2.13/lib/active_record/migration.rb:410:in `migrate'
/usr/lib/ruby/1.8/benchmark.rb:293:in `measure'
/var/lib/gems/1.8/gems/activerecord-3.2.13/lib/active_record/migration.rb:410:in `migrate'
/var/lib/gems/1.8/gems/activerecord-3.2.13/lib/active_record/connection_adapters/abstract/connection_pool.rb:129:in `with_connection'
/var/lib/gems/1.8/gems/activerecord-3.2.13/lib/active_record/migration.rb:389:in `migrate'
/var/lib/gems/1.8/gems/activerecord-3.2.13/lib/active_record/migration.rb:528:in `__send__'
/var/lib/gems/1.8/gems/activerecord-3.2.13/lib/active_record/migration.rb:528:in `migrate'
/var/lib/gems/1.8/gems/activerecord-3.2.13/lib/active_record/migration.rb:720:in `migrate'
/var/lib/gems/1.8/gems/activerecord-3.2.13/lib/active_record/migration.rb:777:in `call'
/var/lib/gems/1.8/gems/activerecord-3.2.13/lib/active_record/migration.rb:777:in `ddl_transaction'
/var/lib/gems/1.8/gems/activerecord-3.2.13/lib/active_record/migration.rb:719:in `migrate'
/var/lib/gems/1.8/gems/activerecord-3.2.13/lib/active_record/migration.rb:700:in `each'
/var/lib/gems/1.8/gems/activerecord-3.2.13/lib/active_record/migration.rb:700:in `migrate'
/var/lib/gems/1.8/gems/activerecord-3.2.13/lib/active_record/migration.rb:570:in `up'
/var/lib/gems/1.8/gems/activerecord-3.2.13/lib/active_record/migration.rb:551:in `migrate'
/var/lib/gems/1.8/gems/activerecord-3.2.13/lib/active_record/railties/databases.rake:193
/usr/lib/ruby/1.8/rake.rb:636:in `call'
/usr/lib/ruby/1.8/rake.rb:636:in `execute'
/usr/lib/ruby/1.8/rake.rb:631:in `each'
/usr/lib/ruby/1.8/rake.rb:631:in `execute'
/usr/lib/ruby/1.8/rake.rb:597:in `invoke_with_call_chain'
/usr/lib/ruby/1.8/monitor.rb:242:in `synchronize'
/usr/lib/ruby/1.8/rake.rb:590:in `invoke_with_call_chain'
/usr/lib/ruby/1.8/rake.rb:583:in `invoke'
/usr/lib/ruby/1.8/rake.rb:2051:in `invoke_task'
/usr/lib/ruby/1.8/rake.rb:2029:in `top_level'
/usr/lib/ruby/1.8/rake.rb:2029:in `each'
/usr/lib/ruby/1.8/rake.rb:2029:in `top_level'
/usr/lib/ruby/1.8/rake.rb:2068:in `standard_exception_handling'
/usr/lib/ruby/1.8/rake.rb:2023:in `top_level'
/usr/lib/ruby/1.8/rake.rb:2001:in `run'
/usr/lib/ruby/1.8/rake.rb:2068:in `standard_exception_handling'
/usr/lib/ruby/1.8/rake.rb:1998:in `run'
/usr/bin/rake:28
问题似乎是 project.inherit_members_changed?不存在,但在 project.rb 的第 85 行被调用
after_save :update_inherited_members, :if => Proc.new {|project| project.inherit_members_changed?}
有谁知道这个问题的根源是什么?
::更新::
我现在尝试升级到 ruby 1.9.3 并得到同样的错误。
rake db:migrate RAILS_ENV=production
== BuildProjectsTree: migrating ==============================================
rake aborted!
An error has occurred, all later migrations canceled:
undefined method `inherit_members_changed?' for #<Project:0x00000004b36d80>
可能是rake版本问题?
我也运行了 bundle install 并安装了所有需要的 gem。