mirror of
https://github.com/ditkrg/active_model_serializers.git
synced 2026-01-25 07:16:49 +00:00
When caching, return the object's cache_key up front if it's defined.
This will prevent objects PORO objects that don't have updated_at defined, from throwing an error. Not as big a deal now that PORO objects can inherit ActiveModelSerializers::Model, but still necessary if it's not inherited for whatever reason. Add the Adapter type to the cache key. This prevents incorrect results when the same object is serialized with different adapters. BF: Cherry-pick of040a97b9e9which was a squash off89ed71058from pr 1346
This commit is contained in:
committed by
Benjamin Fleischer
parent
b73b780b79
commit
ab6bd600e3
4
test/fixtures/poro.rb
vendored
4
test/fixtures/poro.rb
vendored
@@ -55,8 +55,8 @@ Bio = Class.new(Model)
|
||||
Blog = Class.new(Model) do
|
||||
FILE_DIGEST = Digest::MD5.hexdigest(File.open(__FILE__).read)
|
||||
|
||||
def cache_key_with_digest
|
||||
"#{cache_key}/#{FILE_DIGEST}"
|
||||
def digest
|
||||
FILE_DIGEST
|
||||
end
|
||||
end
|
||||
Role = Class.new(Model)
|
||||
|
||||
Reference in New Issue
Block a user