Cache issue with attr_accessor field

Hi,

I’ve got a model with the following attribute added:

attr_accessor :level

which does not exist in the database. After putting instances of this
model in the cache (using Rails.cache.fetch(‘foo’) { Category.all } ),
when I retrieve it back from the cache, then trying to access .level
gives:

undefined method `level’ for #Category:0x34d50a0

I’m simply using the memorystore. In script/console it works fine,
just not when in script/server. Anybody knows what’s happening here?

Best regards,
Jimmy

On Jun 24, 6:50 am, Jimmy [email protected] wrote:

undefined method `level’ for #Category:0x34d50a0

I suspect rails’ automatic reloading is tripping you up here. If it
works when you enable class caching (in development.rb) then it’s
definitely the automatic reloading.

Fred