Skip to content
This repository
Browse code

:joins => joins

  • Loading branch information...
commit b2816ae97173839176ccb982b3dc48854f1fc280 1 parent c4bd477
Akira Matsuda authored July 08, 2011
24  activerecord/lib/active_record/associations.rb
@@ -763,43 +763,43 @@ def association_instance_set(name, association)
763 763
     # second time, the table is aliased as <tt>#{reflection_name}_#{parent_table_name}</tt>.
764 764
     # Indexes are appended for any more successive uses of the table name.
765 765
     #
766  
-    #   Post.all :joins => :comments
  766
+    #   Post.joins(:comments)
767 767
     #   # => SELECT ... FROM posts INNER JOIN comments ON ...
768  
-    #   Post.all :joins => :special_comments # STI
  768
+    #   Post.joins(:special_comments) # STI
769 769
     #   # => SELECT ... FROM posts INNER JOIN comments ON ... AND comments.type = 'SpecialComment'
770  
-    #   Post.all :joins => [:comments, :special_comments] # special_comments is the reflection name, posts is the parent table name
  770
+    #   Post.joins(:comments, :special_comments) # special_comments is the reflection name, posts is the parent table name
771 771
     #   # => SELECT ... FROM posts INNER JOIN comments ON ... INNER JOIN comments special_comments_posts
772 772
     #
773 773
     # Acts as tree example:
774 774
     #
775  
-    #   TreeMixin.all :joins => :children
  775
+    #   TreeMixin.joins(:children)
776 776
     #   # => SELECT ... FROM mixins INNER JOIN mixins childrens_mixins ...
777  
-    #   TreeMixin.all :joins => {:children => :parent}
  777
+    #   TreeMixin.joins(:children => :parent)
778 778
     #   # => SELECT ... FROM mixins INNER JOIN mixins childrens_mixins ...
779 779
     #                               INNER JOIN parents_mixins ...
780  
-    #   TreeMixin.all :joins => {:children => {:parent => :children}}
  780
+    #   TreeMixin.joins(:children => {:parent => :children})
781 781
     #   # => SELECT ... FROM mixins INNER JOIN mixins childrens_mixins ...
782 782
     #                               INNER JOIN parents_mixins ...
783 783
     #                               INNER JOIN mixins childrens_mixins_2
784 784
     #
785 785
     # Has and Belongs to Many join tables use the same idea, but add a <tt>_join</tt> suffix:
786 786
     #
787  
-    #   Post.all :joins => :categories
  787
+    #   Post.joins(:categories)
788 788
     #   # => SELECT ... FROM posts INNER JOIN categories_posts ... INNER JOIN categories ...
789  
-    #   Post.all :joins => {:categories => :posts}
  789
+    #   Post.joins(:categories => :posts)
790 790
     #   # => SELECT ... FROM posts INNER JOIN categories_posts ... INNER JOIN categories ...
791 791
     #                              INNER JOIN categories_posts posts_categories_join INNER JOIN posts posts_categories
792  
-    #   Post.all :joins => {:categories => {:posts => :categories}}
  792
+    #   Post.joins(:categories => {:posts => :categories})
793 793
     #   # => SELECT ... FROM posts INNER JOIN categories_posts ... INNER JOIN categories ...
794 794
     #                              INNER JOIN categories_posts posts_categories_join INNER JOIN posts posts_categories
795 795
     #                              INNER JOIN categories_posts categories_posts_join INNER JOIN categories categories_posts_2
796 796
     #
797  
-    # If you wish to specify your own custom joins using a <tt>:joins</tt> option, those table
  797
+    # If you wish to specify your own custom joins using <tt>joins</tt> method, those table
798 798
     # names will take precedence over the eager associations:
799 799
     #
800  
-    #   Post.all :joins => :comments, :joins => "inner join comments ..."
  800
+    #   Post.joins(:comments).joins("inner join comments ...")
801 801
     #   # => SELECT ... FROM posts INNER JOIN comments_posts ON ... INNER JOIN comments ...
802  
-    #   Post.all :joins => [:comments, :special_comments], :joins => "inner join comments ..."
  802
+    #   Post.joins(:comments, :special_comments).joins("inner join comments ...")
803 803
     #   # => SELECT ... FROM posts INNER JOIN comments comments_posts ON ...
804 804
     #                              INNER JOIN comments special_comments_posts ...
805 805
     #                              INNER JOIN comments ...

0 notes on commit b2816ae

Please sign in to comment.
Something went wrong with that request. Please try again.