Skip to content
This repository
Browse code

Quickref for association methods. Closes #7723.

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@6905 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information...
commit ff6d2aae0a127bb99dcf9e7c4117b2cd0143c088 1 parent 1f80296
Jeremy Kemper authored
2  activerecord/CHANGELOG
... ...
@@ -1,5 +1,7 @@
1 1
 *SVN*
2 2
 
  3
+* Quickref for association methods.  #7723 [marclove, Mindsweeper]
  4
+
3 5
 * Calculations: return nil average instead of 0 when there are no rows to average.  #8298 [davidw]
4 6
 
5 7
 * acts_as_nested_set: direct_children is sorted correctly.  #4761 [Josh Peek, rails@33lc0.net]
43  activerecord/lib/active_record/associations.rb
@@ -101,9 +101,46 @@ def clear_association_cache #:nodoc:
101 101
     # adds a method with that name to its model, it will override the inherited method and break things.
102 102
     # For instance, #attributes and #connection would be bad choices for association names.
103 103
     #
104  
-    # == Example
105  
-    #
106  
-    # link:files/examples/associations.png
  104
+    # == Auto-generated methods
  105
+    #
  106
+    # ===Singular associations (one-to-one)
  107
+    #                                     |            |  belongs_to  |
  108
+    #   generated methods                 | belongs_to | :polymorphic | has_one
  109
+    #   ----------------------------------+------------+--------------+---------
  110
+    #   #other                            |     X      |      X       |    X
  111
+    #   #other=(other)                    |     X      |      X       |    X
  112
+    #   #build_other(attributes={})       |     X      |              |    X
  113
+    #   #create_other(attributes={})      |     X      |              |    X
  114
+    #   #other.create!(attributes={})     |            |              |    X
  115
+    #   #other.nil?                       |     X      |      X       |    
  116
+    #
  117
+    # ===Collection associations (one-to-many / many-to-many)
  118
+    #                                     |       |          | has_many
  119
+    #   generated methods                 | habtm | has_many | :through  
  120
+    #   ----------------------------------+-------+----------+----------
  121
+    #   #others                           |   X   |    X     |    X
  122
+    #   #others=(other,other,...)         |   X   |    X     |    
  123
+    #   #other_ids                        |   X   |    X     |    
  124
+    #   #other_ids=(id,id,...)            |   X   |    X     |    
  125
+    #   #others<<                         |   X   |    X     |    X
  126
+    #   #others.push                      |   X   |    X     |    X
  127
+    #   #others.concat                    |   X   |    X     |    X
  128
+    #   #others.build(attributes={})      |   X   |    X     |    X
  129
+    #   #others.create(attributes={})     |   X   |    X     |    
  130
+    #   #others.create!(attributes={})    |   X   |    X     |    X
  131
+    #   #others.size                      |   X   |    X     |    
  132
+    #   #others.length                    |   X   |    X     |    
  133
+    #   #others.count                     |       |    X     |    
  134
+    #   #others.sum(args*,&block)         |   X   |    X     |    X
  135
+    #   #others.empty?                    |   X   |    X     |    
  136
+    #   #others.clear                     |   X   |    X     |    
  137
+    #   #others.delete(other,other,...)   |   X   |    X     |    X
  138
+    #   #others.delete_all                |   X   |    X     |    
  139
+    #   #others.destroy_all               |   X   |    X     |    
  140
+    #   #others.find(*args)               |   X   |    X     |    X
  141
+    #   #others.find_first                |   X   |          |    
  142
+    #   #others.uniq                      |   X   |    X     |    
  143
+    #   #others.reset                     |   X   |    X     |    X
107 144
     #
108 145
     # == Cardinality and associations
109 146
     # 

0 notes on commit ff6d2aa

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