Can't override class method with monkey patching in Ruby on Rails -


so trying override class method reflect_on_association in activerecord::reflection. here's link original file: https://github.com/rails/rails/blob/master/activerecord/lib/active_record/reflection.rb

the method defined on line 106.

these attempts far:

1.

activerecord::reflection::classmethods.module_eval   # test method   def say_hello     puts 'hello'   end    # want override original method 1   def reflect_on_association(association)     puts 'overridden!'     # < implementation goes here >   end end 

2.

module activerecord::reflection::classmethods   # test method   def say_hello     puts 'hello'   end    # want override original method 1   def reflect_on_association(association)     puts 'overridden!'     # < implementation goes here >   end end 

the say_hello methods works both cases (for example when call person.say_hello), still no luck reflect_on_association.

anyone has idea on how can this? thank much!

working in may case!

make sure passing parameter reflect_on_association.

1.9.3-p551 :514 > person.reflect_on_association(state) overridden! => nil  

Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

Rendering JButton to get the JCheckBox behavior in a JTable by using images does not update my table -