Christos Zisopoulos
2007-Jun-12 12:06 UTC
alias_method_chain and Class methods (a Ruby question)
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 --~--~---------~--~----~------------~-------~--~----~ 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Christos Zisopoulos
2007-Jun-19 20:25 UTC
alias_method_chain and Class methods (a Ruby question)
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 --~--~---------~--~----~------------~-------~--~----~ 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Apparently Analagous Threads
- alias_method_chain and ActiveSupport::TestCase
- undefined method `alias_method_chain' for I18n::Backend::Simple:Class
- undefined method ''alias_method_chain''
- alias_method_chain in Facebooker Causing Stack Level Too Deep
- alias_method_chain stack level too deep in Rake test only