On Apr 8, 2:18 pm, Alex Shulgin <[email protected]> wrote:
> Hello,
>
> I'm facing this problem while trying to extend the parse_redmine_links
> helper method in Redmine-1.1.0 (Rails-2.3.5) from my plugin.
>
> My idea is to use alias_method_chain so the extended version could
> call the original version and adjust the result to it's liking.
>
> Anything I've tried so far exposes this behavior: the first render of
> a page uses the extended version, while every later renders use the
> original unmodified helper.
>
Because you're in development mode, the app's code, including
application_helper is reloaded for each request, but your plugin's
init.rb is only called once and never gets to do your monkey patching
on the reloaded copies of application helper

You might be able to use a to_prepare callback (these get called
before each request in development mode) if you're going to use this a
lot in development mode - take a peek inside action_dispatch/
middleware/callbacks

Fred
> I've tried to include my patch module in the plugin's init.rb like
> this:
>
> require_dependency 'application_helper'
> ApplicationHelper.send(:include,
> RedminePastebin::ApplicationHelperPatch)
>
> Also I've tried to define my ApplicationHelper in myplugin/app/helper/
> application_helper.rb with the same effect.  Both approaches used
> self.included hook to call alias_method_chain, like this:
>
>   def self.included(base)
>     base.module_eval do
>       alias_method_chain :parse_redmine_links, :pastes
>     end
>   end
>
> Any ideas on how to accomplish the task are welcome!
> --
> Alex

-- 
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 [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to