# BetterNestedSet and Rails Caching

**URL:** <https://www.ruby-forum.com/t/betternestedset-and-rails-caching/150413>\
**Category:** Rails\
**Created:** [October 8, 2008, 10:34am UTC](https://www.ruby-forum.com/t/betternestedset-and-rails-caching/150413 "2008-10-08T10:34:17Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [October 8, 2008, 10:34am UTC](https://www.ruby-forum.com/t/betternestedset-and-rails-caching/150413/1 "2008-10-08T10:34:17Z")

</div>

Hi,

we have a simple category structure which is using BetterNestedSet. We  
also use the caching functionality of Rails 2.1. In the development  
environment

config.cache\_classes = false  
config.cache\_store = :memory\_store

this little action

def level\_test  
cat = Rails.cache.fetch(“category”) do  
Category.first  
end  
render :text =\> “#{cat.level}”  
end

breaks when the cache is hit (the second call to the action) telling  
me that the Category class does not implement the “level” method. This  
problem can be fixed turning cache\_classes to true.

Why is acts\_as\_nested\_set not called initializing the Category class  
at the second request?

Thanx,

Tobi
