11

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.

halfer
  • 19,824
  • 17
  • 99
  • 186
Pardeep Dhingra
  • 3,916
  • 7
  • 30
  • 56
  • Check this blog post http://bloggershetty.blogspot.in/2007/04/ruby-typeerror-singleton-cant-be-dumped.html could help you :) – Pavan Jul 13 '15 at 15:37

1 Answers1

1

Gem activeresource-response was causing that problem. It was making my class singleton. Because of that it was throughing singleton dump error.

Pardeep Dhingra
  • 3,916
  • 7
  • 30
  • 56