diff --git a/lib/extensions/active_record/reflection.rb b/lib/extensions/active_record/reflection.rb index dd9a113..6b5c942 100644 --- a/lib/extensions/active_record/reflection.rb +++ b/lib/extensions/active_record/reflection.rb @@ -1,20 +1,12 @@ - # on STI classes tike Article and Profile, plugins' extensions # on associations should be reflected on descendants module ActiveRecord module Reflection - - class << self - - def add_reflection_with_descendants(ar, name, reflection) - self.add_reflection_without_descendants ar, name, reflection - ar.descendants.each do |k| - k._reflections.merge!(name.to_s => reflection) - end if ar.base_class == ar + def self.add_reflection(ar, name, reflection) + (ar.descendants << ar).each do |klass| + klass.clear_reflections_cache + klass._reflections = klass._reflections.merge(name.to_s => reflection) end - - alias_method_chain :add_reflection, :descendants - end end end -- libgit2 0.21.2