Permalink
Browse files

association_basics, updated how inverse_of works

Fixed bug in the example code. A bit related to rails issue in
 #3223
  • Loading branch information...
1 parent 7c58425 commit 8cb9460437eddde6952fbebbc969203cd4d00294 @holli holli committed Aug 20, 2012
Showing with 3 additions and 2 deletions.
  1. +3 −2 guides/source/association_basics.textile
@@ -520,7 +520,7 @@ By default, Active Record doesn't know about the connection between these associ
<ruby>
c = Customer.first
-o = c.orders.first
+o = c.orders[0]
c.first_name == o.customer.first_name # => true
c.first_name = 'Manny'
c.first_name == o.customer.first_name # => false
@@ -542,14 +542,15 @@ With these changes, Active Record will only load one copy of the customer object
<ruby>
c = Customer.first
-o = c.orders.first
+o = c.orders[0]
c.first_name == o.customer.first_name # => true
c.first_name = 'Manny'
c.first_name == o.customer.first_name # => true
</ruby>
There are a few limitations to +inverse_of+ support:
+* They do not work with methods that invoke new query. E.g. using c.orders.first instead of c.orders[0] in the code above
* They do not work with <tt>:through</tt> associations.
* They do not work with <tt>:polymorphic</tt> associations.
* They do not work with <tt>:as</tt> associations.

0 comments on commit 8cb9460

Please sign in to comment.