public
Description: An ActiveRecord plugin for self-referential and double-sided polymorphic associations.
Homepage: http://blog.evanweaver.com/files/doc/fauna/has_many_polymorphs/
Clone URL: git://github.com/fauna/has_many_polymorphs.git
Fixed hmp for edgerails 2.2
snusnu (author)
Fri Oct 17 08:16:49 -0700 2008
commit  e11df9eaec1bc529e05816476d87c76c54755fb2
tree    8dd691dd382cbd464080a1d9a7b476f3ab9d20b7
parent  d343f39684df3cc945491edbd7bce776642ab378
...
2
3
4
5
6
 
7
8
9
10
 
 
11
12
13
 
14
15
16
17
18
19
...
2
3
4
 
 
5
6
7
8
 
9
10
11
12
 
13
14
15
 
16
17
18
0
@@ -2,18 +2,17 @@ module ActiveRecord #:nodoc:
0
   module Reflection #:nodoc:
0
     
0
     module ClassMethods #:nodoc:
0
-  
0
-      # Update the default reflection switch so that <tt>:has_many_polymorphs</tt> types get instantiated. It's not a composed method so we have to override the whole thing.
0
+      
0
       def create_reflection(macro, name, options, active_record)
0
         case macro
0
           when :has_many, :belongs_to, :has_one, :has_and_belongs_to_many
0
-            reflection = AssociationReflection.new(macro, name, options, active_record)
0
+            klass = options[:through] ? ThroughReflection : AssociationReflection
0
+            reflection = klass.new(macro, name, options, active_record)
0
           when :composed_of
0
             reflection = AggregateReflection.new(macro, name, options, active_record)
0
-        # added by has_many_polymorphs #
0
+          # added by has_many_polymorphs #
0
           when :has_many_polymorphs
0
             reflection = PolymorphicReflection.new(macro, name, options, active_record)
0
-        # end added #
0
         end
0
         write_inheritable_hash :reflections, name => reflection
0
         reflection

Comments

tamersalama Mon Nov 17 21:20:46 -0800 2008

This seems to have broken the plugin for Rails 2.1.x

fauna Mon Nov 17 21:50:19 -0800 2008

Hmm. I guess I need a conditional patch.