Forum: Ruby on Rails Possible Bug with intercept calls with alias_method

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Dc906dfeaa19b1d9872255515eea4aba?d=identicon&s=25 paulchin (Guest)
on 2005-12-05 07:26
(Received via mailing list)
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
821395fe70906c8290df7f18ac4ac6cf?d=identicon&s=25 technoweenie (Guest)
on 2005-12-05 07:51
(Received via mailing list)
On 12/5/05, Paul Chin <paulchin@sabah.net.my> 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
782087ddb89779ec817ca1e5b9903166?d=identicon&s=25 Lachlan Laycock (supagroova)
on 2006-05-11 04:09
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?
This topic is locked and can not be replied to.