# Memached failing in 2.1 - not loading classes

**URL:** <https://www.ruby-forum.com/t/memached-failing-in-2-1-not-loading-classes/149444>\
**Category:** Rails\
**Created:** [September 24, 2008, 11:13pm UTC](https://www.ruby-forum.com/t/memached-failing-in-2-1-not-loading-classes/149444 "2008-09-24T23:13:12Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![seanhussey](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/a88e57/32.png) [@seanhussey](https://www.ruby-forum.com/u/seanhussey)\
**Post date:** [September 24, 2008, 11:13pm UTC](https://www.ruby-forum.com/t/memached-failing-in-2-1-not-loading-classes/149444/1 "2008-09-24T23:13:12Z")

</div>

Hi everyone,

We’re setting up memcached with Rails 2.1 and we’re hitting an error  
with some classes. For instance:

Rails.cache.fetch(‘all\_categories’) {Category.all}  
ArgumentError: undefined class/module Category  
from  
/opt/ruby-ee/lib/ruby/gems/1.8/gems/activesupport-2.1.0/lib/active\_support/vendor/memcache-client-1.5.0/memcache.rb:241:in  
`load' from /opt/ruby-ee/lib/ruby/gems/1.8/gems/activesupport-2.1.0/lib/active_support/vendor/memcache-client-1.5.0/memcache.rb:241:in`get’  
from  
/opt/ruby-ee/lib/ruby/gems/1.8/gems/activesupport-2.1.0/lib/active\_support/cache/mem\_cache\_store.rb:26:in  
`read' from /opt/ruby-ee/lib/ruby/gems/1.8/gems/activesupport-2.1.0/lib/active_support/cache.rb:55:in`fetch’  
from (irb):1

If I drop into the debugger, the error comes up on line 214 in  
memcache.rb:

value = Marshal.load value unless raw

When it’s loading the data, it can’t figure out what Category is.  
It’s a normal model. Why isn’t it loaded at this point in the app?

Thanks,

Sean

---

<div class="post-metadata">

**Author:** ![seanhussey](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/a88e57/32.png) [@seanhussey](https://www.ruby-forum.com/u/seanhussey)\
**Post date:** [September 24, 2008, 11:19pm UTC](https://www.ruby-forum.com/t/memached-failing-in-2-1-not-loading-classes/149444/2 "2008-09-24T23:19:40Z")

</div>

Sent too soon. Wanted to add that if I run the cache call and watch  
it fail (and it’ll fail over and over again), then just call:

Category

And then run the call again, it works.

Also, there are other models where this seems to work ok. I can’t  
find the difference except that perhaps those models are being called  
somewhere in the stack before the cache call is made.

Thanks,

Sean
