activerecord-collection_cache_key 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ccd76e94d73ec763de6290eaae3ec459221513c1
4
- data.tar.gz: 525b88d710b5a74411060ed912651a71ff79fb0a
3
+ metadata.gz: 07aede839494b5c41542a32614738d6a69c5200b
4
+ data.tar.gz: 88b7d562178f81990b67a3ece77f87c8a7358613
5
5
  SHA512:
6
- metadata.gz: 788fcb1ebfcd065bd3786b8a7ef7d52b2b74e1e04660ebd5756689ea37f10bc607f5f4251ea2317750477674c1d66a4fbcaf7edea9341f658b9dc1109a9a4553
7
- data.tar.gz: 1ef020a747534e3a6949f54d098a0ebedaa8855e9f8d37d086f31db6a25679e6321c40086306b8902635e3016c1ace119ab9f6844ab58704aee16ccb6ebbc81e
6
+ metadata.gz: 9d7f20f5dbe207988d0d2cfe70c9e75b7e9511bf9177fa56b561c68494738485cbd2c65cbe25268855d03f0b0bbebb44d3da7ea7a3cab099bce99c96ec832419
7
+ data.tar.gz: 808cdcec63c9bf56722949ac2332b246a0f6fca6213534af569988edec89fa8c0857fc24f4f022668d490205c2229c3131dc9f914e0bcaec83f520227a8fabb1
@@ -16,3 +16,11 @@ Bugfix
16
16
 
17
17
  * Corrects a bug where models with a `#size` or `#timestamp` method could
18
18
  fail to generate a proper cache key.
19
+
20
+ ## v0.1.2 - 2016-04-26
21
+
22
+ Bugfix
23
+
24
+ * Corrects a bug in the PostgreSQL adapter where calling `first` when getting collection stats
25
+ adds an implicit `order_by` on an unselected column.
26
+
data/README.md CHANGED
@@ -21,12 +21,15 @@ You can now access the key for any ActiveRecord collection via its `#cache_key`
21
21
  @scope = MyModel.where(active: 1).cache_key
22
22
  ```
23
23
 
24
- And then use it in your view:
24
+ And then use it in your controller:
25
25
 
26
- ```erb
27
- <% cache @scope do %>
28
- <% # some code that renders your collection %>
29
- <% end %>
26
+ ```ruby
27
+ def index
28
+ @scope = MyModel.where(active: 1)
29
+ Rails.cache.fetch(@scope.cache_key) do
30
+ respond_with(@scope)
31
+ end
32
+ end
30
33
  ```
31
34
 
32
35
  **Notes on Rails 3.x and `.all`:**
@@ -24,7 +24,7 @@ module CollectionCacheKey
24
24
  def details_for(collection, timestamp_column)
25
25
  column = "#{connection.quote_table_name(collection.table_name)}.#{connection.quote_column_name(timestamp_column)}"
26
26
  query = collection.dup
27
- result = query.select("COUNT(*) AS size, MAX(#{column}) AS timestamp").first
27
+ result = query.select("COUNT(*) AS size, MAX(#{column}) AS timestamp").to_a.first
28
28
  attrs = result.attributes
29
29
 
30
30
  [query_key(collection), attrs['size'], parsed_timestamp(attrs['timestamp'])]
@@ -2,7 +2,7 @@ module CollectionCacheKey
2
2
  module VERSION
3
3
  MAJOR = 0
4
4
  MINOR = 1
5
- PATCH = 1
5
+ PATCH = 2
6
6
  PRE = nil
7
7
  STRING = [MAJOR, MINOR, PATCH, PRE].compact.join('.')
8
8
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activerecord-collection_cache_key
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dan Drinkard
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-04-01 00:00:00.000000000 Z
11
+ date: 2016-04-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord