1
0
Fork 0
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:
Sammy Larbi 2016-03-28 09:03:02 -05:00
parent 475109c517
commit 53db086e60

View file

@ -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
```