Using cached_resource gem for caching active resources.
User model
class User < ActiveResource::Base
cached_resource
class teachers < SimpleDelegator
attr_accessor :teacher_id
def initialize(attributes = {}, _persisted = true)
@teacher_id = attributes['teacher_id']
super(User.find(@teacher_id))
end
end
end
I am trying to cache user resources.
/users/:user_id
Whenever I am calling /users/:user_id endpoint it gives me error singleton can't be dumped at line super(User.find(@teacher_id))
Please suggest if any other gem can help me in caching activeresource calls.
Gem activeresource-response
was causing that problem. It was making my class singleton. Because of that it was throughing singleton dump error.