# Eval class when config.cache\_classes = true

**URL:** <https://www.ruby-forum.com/t/eval-class-when-config-cache-classes-true/113295>\
**Category:** Rails\
**Created:** [August 29, 2007, 5:08pm UTC](https://www.ruby-forum.com/t/eval-class-when-config-cache-classes-true/113295 "2007-08-29T17:08:48Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![linus](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/f4b2a3/32.png) [@linus](https://www.ruby-forum.com/u/linus)\
**Post date:** [August 29, 2007, 5:08pm UTC](https://www.ruby-forum.com/t/eval-class-when-config-cache-classes-true/113295/1 "2007-08-29T17:08:48Z")

</div>

Hi,  
I have problem with config.cache\_classes = true.  
After turning it on, the current\_user in tabnav file  
definition is not updated.

class Tabnav::MainTabnav \< Tabnav::Base  
current\_user = User.find(Thread.current[‘user’])

```
if current_user.has_role? Role::ADMIN
   add_tab do
      named ''
      iconed '/images/layout/icons/admin_icon.png'
      links_to :controller => '/users'
      highlights_on :controller => 'users'
   end
end

```

…

When I try:

class Symbol  
def to\_tabnav  
file\_name = ‘tabnav/’ + self.id2name + ‘\_tabnav’  
load( File.join( File::expand\_path(RAILS\_ROOT), ‘app’, ‘models’,  
file\_name + ‘.rb’ ) )  
eval(file\_name.camelcase).instance  
end  
end

I get user updated, but the code of class is executed twice:  
one with load and then with eval(file\_name.camelcase).

Because I need to return eval(file\_name.camelcase).instance,  
But I also need the file to be always up tu date.

Any idea how I might solve it?

Cheers,  
Tomasz Bak
