aboutsummaryrefslogtreecommitdiffstats
path: root/guides
diff options
context:
space:
mode:
authorRafael França <rafaelmfranca@gmail.com>2017-08-08 15:12:04 -0400
committerGitHub <noreply@github.com>2017-08-08 15:12:04 -0400
commit27f18cc684e22933db5b43375a85060931abb224 (patch)
tree706ac31b8dd9cd84ee440b5d521d0fdd4621b5c8 /guides
parent21c9c5782e0eaf00769e01164e73d3fa6d3709ac (diff)
parentf2810f1dab649b2999fa0ad991ddabb416c5be74 (diff)
downloadrails-27f18cc684e22933db5b43375a85060931abb224.tar.gz
rails-27f18cc684e22933db5b43375a85060931abb224.tar.bz2
rails-27f18cc684e22933db5b43375a85060931abb224.zip
Merge pull request #30125 from yukideluxe/add-reload-to-associations-docs
add reload_association to documentation
Diffstat (limited to 'guides')
-rw-r--r--guides/source/association_basics.md10
1 files changed, 6 insertions, 4 deletions
diff --git a/guides/source/association_basics.md b/guides/source/association_basics.md
index bead931529..44228de591 100644
--- a/guides/source/association_basics.md
+++ b/guides/source/association_basics.md
@@ -811,6 +811,7 @@ When you declare a `belongs_to` association, the declaring class automatically g
* `build_association(attributes = {})`
* `create_association(attributes = {})`
* `create_association!(attributes = {})`
+* `reload_association`
In all of these methods, `association` is replaced with the symbol passed as the first argument to `belongs_to`. For example, given the declaration:
@@ -840,10 +841,10 @@ The `association` method returns the associated object, if any. If no associated
@author = @book.author
```
-If the associated object has already been retrieved from the database for this object, the cached version will be returned. To override this behavior (and force a database read), call `#reload` on the parent object.
+If the associated object has already been retrieved from the database for this object, the cached version will be returned. To override this behavior (and force a database read), call `#reload_association` on the parent object.
```ruby
-@author = @book.reload.author
+@author = @book.reload_author
```
##### `association=(associate)`
@@ -1161,6 +1162,7 @@ When you declare a `has_one` association, the declaring class automatically gain
* `build_association(attributes = {})`
* `create_association(attributes = {})`
* `create_association!(attributes = {})`
+* `reload_association`
In all of these methods, `association` is replaced with the symbol passed as the first argument to `has_one`. For example, given the declaration:
@@ -1190,10 +1192,10 @@ The `association` method returns the associated object, if any. If no associated
@account = @supplier.account
```
-If the associated object has already been retrieved from the database for this object, the cached version will be returned. To override this behavior (and force a database read), call `#reload` on the parent object.
+If the associated object has already been retrieved from the database for this object, the cached version will be returned. To override this behavior (and force a database read), call `#reload_association` on the parent object.
```ruby
-@account = @supplier.reload.account
+@account = @supplier.reload_account
```
##### `association=(associate)`