Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Singleton can't be dumped - cached_resource gem

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.

like image 858
Pardeep Dhingra Avatar asked Jul 08 '15 11:07

Pardeep Dhingra


1 Answers

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

like image 132
Pardeep Dhingra Avatar answered Oct 14 '22 05:10

Pardeep Dhingra