[Rails] Re: How to extend a helper using plugin?
Is the problem solved?
I found that the following codes works as expected.
redmine/vendor/plugins/redmine_x/init.rb:
require 'redmine'
require 'dispatcher'
module XPatch
def self.included(base) # :nodoc:
if !base.method_defined?(:parse_redmine_links_without_patch)
base.send(:include, InstanceMethods)
base.class_eval do
alias_method_chain :parse_redmine_links, :patch
end
else
base.class_eval do
alias_method :parse_redmine_links, :parse_redmine_links_with_patch
end
end
end
module InstanceMethods
def parse_redmine_links_with_patch(text, project, obj, attr,
only_path, options)
parse_redmine_links_without_patch(text, project, obj, attr,
only_path, options)
text.gsub!(/./, 'x')
end
end
end
Dispatcher.to_prepare :x do
require_dependency 'application_helper'
ApplicationHelper.send(:include, XPatch)
end
Redmine::Plugin.register :redmine_magic_links_to_notes do
name 'Redmine X plugin'
author 'ganaware'
description 'X notes'
version '0.0.1'
end
--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home