public
Description: rails plugin that allows has_many :through to go through other has_many :throughs
Homepage:
Clone URL: git://github.com/ianwhite/nested_has_many_through.git
Fixed failing named_scope specs
ianwhite (author)
Wed Apr 30 05:00:39 -0700 2008
commit  944581b7a08c4421507779042a085e8e5038e310
tree    e3215b4f5f2bac922624ebe38c1b70f94464fb08
parent  50d47663286883e23e39d605cc99dfc9d3163747
...
20
21
22
23
 
24
25
 
26
27
28
...
39
40
41
42
43
44
45
46
 
 
 
47
48
49
...
20
21
22
 
23
24
 
25
26
27
28
...
39
40
41
 
 
 
 
 
42
43
44
45
46
47
0
@@ -20,9 +20,9 @@ module NestedHasManyThrough
0
           "#{@nested_join_attributes[:remote_key]} = #{@owner.quoted_id} #{@nested_join_attributes[:conditions]}"
0
         end
0
 
0
-        def construct_joins
0
+        def construct_joins(custom_joins = nil)
0
           @nested_join_attributes ||= construct_nested_join_attributes
0
-          @nested_join_attributes[:joins]
0
+          "#{@nested_join_attributes[:joins]} #{custom_joins}"
0
         end
0
       end
0
     end
0
@@ -39,11 +39,9 @@ module NestedHasManyThrough
0
     #   take part in the join
0
     # * <tt>:conditions</tt>: any additional conditions (e.g. filtering by type for a polymorphic association,
0
     #    or a :conditions clause explicitly given in the association), including a leading AND
0
-    def construct_nested_join_attributes(
0
-      reflection = @reflection,
0
-      association_class = reflection.klass,
0
-      table_ids = {association_class.table_name => 1})
0
-
0
+    def construct_nested_join_attributes( reflection = @reflection, 
0
+                                          association_class = reflection.klass,
0
+                                          table_ids = {association_class.table_name => 1})
0
       if reflection.macro == :has_many && reflection.through_reflection
0
         construct_has_many_through_attributes(reflection, table_ids)
0
       else
...
66
67
68
69
 
70
71
72
...
66
67
68
 
69
70
71
72
0
@@ -66,7 +66,7 @@ class Post < ActiveRecord::Base
0
   end
0
 
0
   # only test named_scope in edge
0
-  named_scope(:inflamatory) if respond_to?(:named_scope)
0
+  named_scope(:inflamatory, :conditions => {:inflamatory => true}) if respond_to?(:named_scope)
0
   
0
   belongs_to :author
0
   belongs_to :category

Comments