Last active
December 20, 2019 04:51
-
-
Save ej2015/07f2959b74eb89740e8ca1a0a4e301b5 to your computer and use it in GitHub Desktop.
Revisions
-
ej2015 renamed this gist
Dec 20, 2019 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
ej2015 revised this gist
Dec 20, 2019 . 1 changed file with 8 additions and 9 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,14 +1,13 @@ Rails cache SQL calls So suppose we have a model Author which has_many Book expect(author.books).to equal author.books If Book has a scope, say by_countries: scope :by_countries, -> c { where(countries: c) if c.present? } scoped queries are not cached: expect(author.books.by_countries(nil)).not_to equal author.books.by_countries(nil) -
ej2015 created this gist
Dec 20, 2019 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,14 @@ Rails cache SQL calls So suppose we have a model Author which has_many Book ``` expect(author.books).to equal author.books ``` If Book has a scope, say by_countries: ``` scope :by_countries, -> c { where(countries: c) if c.present? } ``` scoped queries are not cached: ``` expect(author.books.by_countries(nil)).not_to equal author.books.by_countries(nil) ```