-2
我已經開發了兩個插件,他們都通過alias_method_chain
導致成棧層次過深錯誤修改同一類的同方法。2 alias_method_chain - >堆棧層次過深
第一插件:
Rails.configuration.to_prepare do
require 'issue_patch'
Issue.send :include, IssuePatch
end
module IssuePatch
module InstanceMethods
def editable_custom_field_values_with_sort(user=nil)
editable_custom_field_values_without_sort(user).sort
end
end
def self.included(receiver)
receiver.send :include, InstanceMethods
receiver.class_eval do
alias_method_chain :editable_custom_field_values, :sort
end
end
end
二插件修改類相同,但具有不同的特徵:
Rails.configuration.to_prepare do
require 'issue_patch'
Issue.send :include, IssuePatch
end
module IssuePatch
module InstanceMethods
def editable_custom_field_values_with_some_stuff(user=nil)
editable_custom_field_values_without_some_stuff(user).select { |c| c.have_stuff? }
end
end
def self.included(receiver)
receiver.send :include, InstanceMethods
receiver.class_eval do
alias_method_chain :editable_custom_field_values, :some_stuff
end
end
end
當我試圖調用這個方法我:
ActionView::Template::Error (stack level too deep):
plugins/my_plugin/lib/issue_patch.rb:8
一個可能的,但黑客解決方案是簡單的猴子補丁的第一個插件功能的Redmine代碼,所以秒ond插件可以沒有任何錯誤地將其別名。
那麼我該如何解決這個錯誤?
硬盤沒有看到你在做什麼更新 –
@FrederickCheung問題的話。 – freemanoid