Поэтому я пытаюсь переопределить метод класса reflect_on_association
в ActiveRecord::Reflection
. Вот ссылка на исходный файл: https://github.com/rails/rails/blob/master/activerecord/lib/active_record/reflection.rb
Метод был определен в строке 106.
Это мои попытки до сих пор:
1.
ActiveRecord::Reflection::ClassMethods.module_eval do
# A test method
def say_hello
puts 'hello'
end
# I want to override the original method with this one
def reflect_on_association(association)
puts 'overridden!'
# < Implementation goes here >
end
end
2.
module ActiveRecord::Reflection::ClassMethods
# A test method
def say_hello
puts 'hello'
end
# I want to override the original method with this one
def reflect_on_association(association)
puts 'overridden!'
# < Implementation goes here >
end
end
Методы say_hello
работают в обоих случаях (например, когда я вызываю Person.say_hello
), но все равно не везет с reflect_on_association
.
Кто-нибудь знает, как я могу это сделать? Большое спасибо!
config/initializers
- person joeleba   schedule 15.07.2015