{"action":"closed","issue":{"url":"https://api.github.com/repos/Shopify/identity_cache/issues/258","repository_url":"https://api.github.com/repos/Shopify/identity_cache","labels_url":"https://api.github.com/repos/Shopify/identity_cache/issues/258/labels{/name}","comments_url":"https://api.github.com/repos/Shopify/identity_cache/issues/258/comments","events_url":"https://api.github.com/repos/Shopify/identity_cache/issues/258/events","html_url":"https://github.com/Shopify/identity_cache/issues/258","id":134740158,"number":258,"title":"Ugrading to version 0.3.0 (or 0.3.1) issue: Can't dup NilClass error when accessing coder[:attributes].dup","user":{"login":"rafiaqutab","id":1848389,"avatar_url":"https://avatars.githubusercontent.com/u/1848389?v=3","gravatar_id":"","url":"https://api.github.com/users/rafiaqutab","html_url":"https://github.com/rafiaqutab","followers_url":"https://api.github.com/users/rafiaqutab/followers","following_url":"https://api.github.com/users/rafiaqutab/following{/other_user}","gists_url":"https://api.github.com/users/rafiaqutab/gists{/gist_id}","starred_url":"https://api.github.com/users/rafiaqutab/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rafiaqutab/subscriptions","organizations_url":"https://api.github.com/users/rafiaqutab/orgs","repos_url":"https://api.github.com/users/rafiaqutab/repos","events_url":"https://api.github.com/users/rafiaqutab/events{/privacy}","received_events_url":"https://api.github.com/users/rafiaqutab/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2016-02-19T00:41:48Z","updated_at":"2016-04-03T16:25:27Z","closed_at":"2016-04-03T16:25:27Z","body":"In version 0.2.5 the `record_from_coder` method, found in `lib/identity_cache/query_api.rb` as shown here: \r\n\r\n``` ...line 91: coder['attributes'] = coder['attributes'].dup...```\r\n\r\naccesses the `attributes` key from the `coder` hash using a `String` value. After upgrading to version 0.3.0 (also tried version 0.3.1) the `record_from_coder` method has been changed to access `attributes` key from the `coder` hash using a `Symbol`, as shown here:\r\n\r\n```...line 88: record = klass.instantiate(coder[:attributes].dup)...```\r\n\r\nWhen running our test suite without any any additional changes (only IdentityCache gem upgrade), we received an error:\r\n\r\n```TypeError: can't dup NilClass```\r\n\r\nin the `record_from_coder` method from our custom `ActiveRecord` model which calls the `IdentityCache's` \"included\" method `.fetch_multi(ids)`. The reason seems to be that the `coder` hash has an `attributes` `String` key but not an `:attributes` Symbol key. We are using the latest version of `FactoryGirl` (version 4.5.0) to create this object which was already up-to-date when using `IdentityCache` 0.2.5 version. I am able to make the test pass by doing `IdentityCache.cache.clear` before calling the `.fetch_multi(ids)` which simply skips it from calling the `record_from_coder` method. This would not be the correct solution as we the expected behavior is to access the object from cache.\r\n\r\nI noticed it is the `ActiveSupport's` `coders_by_key` method called in the `IdentityCache's` `fetch_multi` method, as shown here:\r\n\r\n```....line 67: cache_keys.map{ |key| key_to_record_map[key] || record_from_coder(coders_by_key[key]) }...``` \r\n\r\nwhich returns a hash that does not include the `:attributes` symbol key and by doing a `record_from_coder HashWithIndifferentAccess.new(coders_by_key[key])` it seems to fix this issue. However, I am not sure why this is the case for this particular `ActiveRecord` object and not the other `ActiveRecord` objects that are being accessed from the cache (i.e `IdentityCache`) as well.\r\n\r\nKindly provide some feedback."}}