Project

General

Profile

Error while extending Menu Manager in a plugin

Added by Anju P S over 13 years ago

I tried extending menu manager to override menu_items_for method. But keep on getting error as follows;
/menu_manager.rb:28:in `old_initilize': stack level too deep (SystemStackError)
from /usr/share/intero_redmine/lib/redmine/menu_manager.rb:28:in `old_initilize'
from /usr/share/intero_redmine/lib/redmine/menu_manager.rb:28:in `initialize'
from /usr/share/intero_redmine/lib/redmine/menu_manager.rb:420:in `initialize'
from /usr/share/intero_redmine/lib/redmine/menu_manager.rb:355:in `new'
from /usr/share/intero_redmine/lib/redmine/menu_manager.rb:355:in `push'
from /usr/share/intero_redmine/lib/redmine/plugin.rb:178:in `menu'
from /usr/share/intero_redmine/vendor/plugins/redmine_importer/init.rb:12:in `evaluate_init_rb'
from /usr/share/intero_redmine/lib/redmine/plugin.rb:67:in `instance_eval'
... 20 levels...
from /usr/lib/ruby/gems/1.8/gems/rails-2.3.5/lib/commands/server.rb:84
from /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:29:in `gem_original_require'
from /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:29:in `require'
from script/server:3

My patch file is something like this;

require_dependency 'menu_manager'

module MenuManagerPatch
module MenuHelper

def self.included(base) # :nodoc:
base.send(:include, InstanceMethods)
base.alias_method_chain :menu_items_for , :hidden_activity
end
module InstanceMethods
def menu_items_for_with_hidden_activity
// my code
end
end
end
end

MenuManager.send(:include , MenuManagerPatch)

Thanks in advance,
Anju