# Cache issue with attr\_accessor field

**URL:** <https://www.ruby-forum.com/t/cache-issue-with-attr-accessor-field/141287>\
**Category:** Rails\
**Created:** [June 24, 2008, 11:10am UTC](https://www.ruby-forum.com/t/cache-issue-with-attr-accessor-field/141287 "2008-06-24T11:10:59Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![jsoho](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/8baadc/32.png) [@jsoho](https://www.ruby-forum.com/u/jsoho)\
**Post date:** [June 24, 2008, 11:10am UTC](https://www.ruby-forum.com/t/cache-issue-with-attr-accessor-field/141287/1 "2008-06-24T11:10:59Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![jsoho](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/8baadc/32.png) [@jsoho](https://www.ruby-forum.com/u/jsoho)\
**Post date:** [June 24, 2008, 11:15am UTC](https://www.ruby-forum.com/t/cache-issue-with-attr-accessor-field/141287/2 "2008-06-24T11:15:05Z")

</div>

On Jun 24, 6:50 am, Jimmy [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) 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
