[Git][noosfero/noosfero][master] 2 commits: Fixes ActiveRecord relations for descendants

Bráulio Bhavamitra gitlab at mg.gitlab.com
Mon May 16 12:12:28 BRT 2016


Bráulio Bhavamitra pushed to branch master at Noosfero / noosfero


Commits:
77b6d6b9 by Marcos Ronaldo at 2016-05-16T10:06:21-03:00
Fixes ActiveRecord relations for descendants

Temporary fix, waiting for original fix to be merged.

Original author: Jon Moss
Merge Request: https://github.com/rails/rails/pull/24719
Issue: https://github.com/rails/rails/issues/20678

Signed-off-by: Joenio Costa <joenio at colivre.coop.br>
Signed-off-by: Marcos Ronaldo <marcos.rpj2 at gmail.com>
Signed-off-by: Tallys Martins <tallysmartins at gmail.com>

- - - - -
c06b4923 by Bráulio Bhavamitra at 2016-05-16T15:12:10+00:00
Merge branch 'fix_activerecord_relations_inheritance' into 'master'

Fixes ActiveRecord relations for descendants

Temporary fix, waiting for original fix to be merged.

Original author: Jon Moss
Merge Request: https://github.com/rails/rails/pull/24719
Issue: https://github.com/rails/rails/issues/20678

See merge request !914
- - - - -


1 changed file:

- lib/extensions/active_record/reflection.rb


Changes:

=====================================
lib/extensions/active_record/reflection.rb
=====================================
--- 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



View it on GitLab: https://gitlab.com/noosfero/noosfero/compare/82dc3676500f19974136cf925b7c0d14ab8ae89c...c06b49236ed3ef82eac79e0bbe03b5cef013c48e
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listas.softwarelivre.org/pipermail/noosfero-dev/attachments/20160516/8755efbe/attachment-0001.html>


More information about the Noosfero-dev mailing list