Forum: Ruby on Rails alias_method_chain and Class methods (a Ruby question)

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Christos Z. (Guest)
on 2007-06-20 00:26
(Received via mailing list)
Hello list,

I am trying to override the post_form method of Net::HTTP so that it
does something before actually doing the post. I tried the following
in environments/development.rb

   module Net
     class HTTP

     alias_method_chain :post_form, :intercept

     def post_form_with_intercept(url, params)
       # Do something before post'About to post at #{url}')
       post_form_without_intercept(url, params)

Unfortunately this complains that there in no method called post_form:

  ... :NameError: undefined method `post_form' for class

I also tried opening the Net module with:

   module ::Net

but then I get:

  ... :NameError: undefined method `post_form' for class `Net::HTTP'

Any ideas how I can achieve what I want?

This topic is locked and can not be replied to.