使用redmine 3.x,两个插件-redmine subtask list accordion和Subtask list inherited fields之间存在依赖冲突。尝试查看问题时,同时安装两者都会引发500个错误。
actionView::Template::Error (undefined method `sla_has_grandson_issues?' for #<#<Class:0x000056319e27d668>:0x00007f237ad02588>):
1: <% if sla_has_grandson_issues?(@issue) %>
2: <%= content_for :header_tags do
3: stylesheet_link_tag(sla_use_css,:plugin => "redmine_subtask_list_accordion") +
4: javascript_include_tag("subtask_list_accordion" + (subtask_tree_client_processing? ? "_client" : ""),:plugin => "redmine_subtask_list_accordion")
plugins/redmine_subtask_list_accordion/app/views/issues/_subtask_list_accordion_partial.html.erb:1:in `_292e8187f64bee60c61b7b15c99630ab'
经过反复试验,我们通过将以下内容添加到第一个插件的原始源代码中来解决此问题:
included do
alias_method :render_descendants_tree_original,:render_descendants_tree
alias_method :render_descendants_tree,:switch_render_descendants_tree
alias_method :sla_use_css,:sla_use_css
alias_method :switch_render_descendants_tree,:switch_render_descendants_tree
alias_method :render_descendants_tree_accordion,:render_descendants_tree_accordion
alias_method :expand_tree_at_first?,:expand_tree_at_first?
alias_method :sla_has_grandson_issues?,:sla_has_grandson_issues?
alias_method :subtask_tree_client_processing?,:subtask_tree_client_processing?
alias_method :subtask_list_accordion_tree_render_32?,:subtask_list_accordion_tree_render_32?
alias_method :subtask_list_accordion_tree_render_33?,:subtask_list_accordion_tree_render_33?
alias_method :subtask_list_accordion_tree_render_34?,:subtask_list_accordion_tree_render_34?
这是原始代码:
具有上述源代码中的前两个 alias_method 调用。
通过为原始类中的每个方法创建一个具有相同名称的别名方法,代码可以正常工作。但是,这似乎是一个错误修复程序,我不明白为什么有效。有人可以解释该修复程序为何起作用以及如何正确重写它吗?
?