Possible Bug with intercept calls with alias_method


#1

Hi all I’m trying user alias_method to overload the link_to method, It
works the first time, but when I reload the page, it will have an error
“stack level too deep”.

I’m using rails 0.14.3 ruby 1.8.2 Webrick in winxp, I suspect it is a
bug.

this is my helper’s code

module UsersHelper
include ActionView::Helpers::UrlHelper

alias_method :link_to_original, :link_to

def link_to(name, options = {}, html_options =
nil,*parameters_for_method_reference)
if permission?
link_to_original( name,
options,html_options,*parameters_for_method_reference )
end
end

end


#2

On 12/5/05, Paul C. removed_email_address@domain.invalid wrote:

end

It’s probably running that on every request. On the second request it
maps your new link_to to link_to_original. Try surrounding it in
this:

unless respond_to?(:link_to_original)

end


rick
http://techno-weenie.net


#3

technoweenie wrote:

It’s probably running that on every request. On the second request it
maps your new link_to to link_to_original. Try surrounding it in
this:

unless respond_to?(:link_to_original)

end

Hi, I am trying to do the same thing and unfortunately the respond_to?
approach doesn’t have any affect.

Any ideas on how to overload the link_to function?