Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Adding warning for the autoinitializers.

  • Loading branch information...
commit b1dff75b166d1367fb16fad4605cad6591e7d868 1 parent 42e92f5
Federico Builes authored January 26, 2012

Showing 1 changed file with 11 additions and 0 deletions. Show diff stats Hide diff stats

  1. 11  README.md
11  README.md
Source Rendered
@@ -91,7 +91,18 @@ Notes
91 91
   `after_initialize` hook this might overwrite the validations done in `reject_if`.
92 92
 * The option `:append => true` is equivalent to `:count => 1`.
93 93
 * None of the operations will overwrite existing objects.
  94
+* Autobuilding associations means that if there's a value in the column, the object **will be loaded
  95
+every time you load the parent**. This is problematic if you're trying to optimize your code. To get
  96
+a better picture of this:
94 97
 
  98
+    class User
  99
+      has_one :address
  100
+      auto_build :address
  101
+    end
  102
+
  103
+If you do `User.select(:id)` the resulting query will be `SELECT id FROM users;` **plus** `SELECT *
  104
+from addresses WHERE user_id = 42";`. This happens because we're calling calling `user#address`
  105
+every time we initialize a `User` object.
95 106
 
96 107
 How it works
97 108
 ----

0 notes on commit b1dff75

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