aboutsummaryrefslogtreecommitdiffstats
path: root/guides
diff options
context:
space:
mode:
authorOlli Huotari <olli.huotari@iki.fi>2012-08-20 11:17:26 +0300
committerOlli Huotari <olli.huotari@iki.fi>2012-08-20 11:17:26 +0300
commit8cb9460437eddde6952fbebbc969203cd4d00294 (patch)
tree27ffd0fa92d29f9620f6bc0401728c45d49df9b2 /guides
parent7c584256d1d74a72bc9eed9db5aee71e27006515 (diff)
downloadrails-8cb9460437eddde6952fbebbc969203cd4d00294.tar.gz
rails-8cb9460437eddde6952fbebbc969203cd4d00294.tar.bz2
rails-8cb9460437eddde6952fbebbc969203cd4d00294.zip
association_basics, updated how inverse_of works
Fixed bug in the example code. A bit related to rails issue in  https://github.com/rails/rails/issues/3223
Diffstat (limited to 'guides')
-rw-r--r--guides/source/association_basics.textile5
1 files changed, 3 insertions, 2 deletions
diff --git a/guides/source/association_basics.textile b/guides/source/association_basics.textile
index d4c0a1ba74..f6b1a0ef7a 100644
--- a/guides/source/association_basics.textile
+++ b/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,7 +542,7 @@ 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
@@ -550,6 +550,7 @@ c.first_name == o.customer.first_name # => true
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.