# Alias\_method\_chain and Class methods (a Ruby question)

**URL:** <https://www.ruby-forum.com/t/alias-method-chain-and-class-methods-a-ruby-question/106615>\
**Category:** Rails\
**Created:** [June 12, 2007, 2:07pm UTC](https://www.ruby-forum.com/t/alias-method-chain-and-class-methods-a-ruby-question/106615 "2007-06-12T14:07:59Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![christos](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/e36b37/32.png) [@christos](https://www.ruby-forum.com/u/christos)\
**Post date:** [June 12, 2007, 2:07pm UTC](https://www.ruby-forum.com/t/alias-method-chain-and-class-methods-a-ruby-question/106615/1 "2007-06-12T14:07:59Z")

</div>

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
   logger.info('About to post at #{url}')
   post_form_without_intercept(url, params)
 end

```

end

Unfortunately this complains that there in no method called post\_form:

… :NameError: undefined method `post_form' for class`Rails::Initializer::Net::HTTP’

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?

-christos
