mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Update how to clear the association cache
Passing `true` to the association has been deprecated.
This commit is contained in:
parent
475109c517
commit
53db086e60
1 changed files with 2 additions and 2 deletions
|
@ -545,12 +545,12 @@ author.books.size # uses the cached copy of books
|
|||
author.books.empty? # uses the cached copy of books
|
||||
```
|
||||
|
||||
But what if you want to reload the cache, because data might have been changed by some other part of the application? Just pass `true` to the association call:
|
||||
But what if you want to reload the cache, because data might have been changed by some other part of the application? Just call `reload` on the association:
|
||||
|
||||
```ruby
|
||||
author.books # retrieves books from the database
|
||||
author.books.size # uses the cached copy of books
|
||||
author.books(true).empty? # discards the cached copy of books
|
||||
author.books.reload.empty? # discards the cached copy of books
|
||||
# and goes back to the database
|
||||
```
|
||||
|
||||
|
|
Loading…
Reference in a new issue