【发布时间】:2019-08-26 03:16:16
【问题描述】:
我正在运行一个 Redmine 3.4.4 安装,它使用 Ruby 2.2.5-p319 和 Rails 4.2.8。我们想将它升级到需要 Rails 5 的 Redmine 最新版本(当前为 4.0.4)。
我正在使用 Ruby 2.6.3-p62 和 Rails 5.2.3 使用 4.0.4 运行新服务器。总的来说还可以,但是我们安装了一些我们想要迁移的插件。由于 Rails 5 中的弃用,其中许多都遇到了问题。即使我以前没有编写过 Ruby on Rails,我也设法通过 9 个插件中的 8 个,但我被困在最后一个插件上,只是想不通。
该插件是我的页面自定义插件,当我尝试迁移数据库和插件时,我收到此错误:
[centos@redmine]$ bundle exec rake db:migrate RAILS_ENV=production
rake aborted!
NoMethodError: undefined method `alias_method_chain' for ActivitiesController:Class
Did you mean? alias_method
/usr/local/src/redmine-4.0.4/plugins/redmine_my_page/lib/my_page_patches/activities_controller_patch.rb:11:in `block in included'
/usr/local/src/redmine-4.0.4/plugins/redmine_my_page/lib/my_page_patches/activities_controller_patch.rb:7:in `class_eval'
/usr/local/src/redmine-4.0.4/plugins/redmine_my_page/lib/my_page_patches/activities_controller_patch.rb:7:in `included'
/usr/local/src/redmine-4.0.4/plugins/redmine_my_page/init.rb:30:in `include'
/usr/local/src/redmine-4.0.4/plugins/redmine_my_page/init.rb:30:in `block (2 levels) in <top (required)>'
因此,很明显已弃用的'alias_method_chain' 是这里的问题。经过一番挖掘,我在网上找到了很多参考资料,例如 this 一个很好且清晰的参考资料,但我就是无法编写有效的代码 - 我不断收到语法错误,无法弄清楚我在做什么错误的。
这是来自activities_controller_patch.rb:的原始sn-p
module ActivitiesControllerPatch
def self.included(base) # :nodoc:
base.send(:include, InstanceMethods)
base.class_eval do
unloadable
helper :issues
helper :queries
alias_method_chain :index, :esi
end
end
如果可以的话,我们愿意继续使用这个插件,即使它不正式支持 Redmine 4。我希望有更好的 Ruby 知识的人能够提供帮助。
【问题讨论】:
标签: ruby-on-rails-5 redmine-plugins