# Class Caching Problem \[was Newbie Question about Custom Clas

**URL:** <https://www.ruby-forum.com/t/class-caching-problem-was-newbie-question-about-custom-clas/85312>\
**Category:** Rails\
**Created:** [March 22, 2006, 3:19pm UTC](https://www.ruby-forum.com/t/class-caching-problem-was-newbie-question-about-custom-clas/85312 "2006-03-22T15:19:51Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Brent\_J](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/ccd318/32.png) [@Brent\_J](https://www.ruby-forum.com/u/Brent_J)\
**Post date:** [March 22, 2006, 3:19pm UTC](https://www.ruby-forum.com/t/class-caching-problem-was-newbie-question-about-custom-clas/85312/1 "2006-03-22T15:19:51Z")

</div>

So any other ideas as to why my custom class under app/models is being  
cached even though all the caching is set to false in the  
config/environments/\* files? Currently I’m having to restart WEBrick  
after EVERY change to the file. The controllers and views are  
reloading just fine and not being cached. It’s just the custom class  
I created that’s being cached.

Any ideas as to what I should try to get it to stop caching the class?

Thanks,

- Brent

---

<div class="post-metadata">

**Author:** ![Brent\_J](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/ccd318/32.png) [@Brent\_J](https://www.ruby-forum.com/u/Brent_J)\
**Post date:** [March 22, 2006, 3:28pm UTC](https://www.ruby-forum.com/t/class-caching-problem-was-newbie-question-about-custom-clas/85312/2 "2006-03-22T15:28:21Z")

</div>

Hi –

On Wed, 22 Mar 2006, Brent J. wrote:

> So any other ideas as to why my custom class under app/models is being  
> cached even though all the caching is set to false in the  
> config/environments/\* files? Currently I’m having to restart WEBrick  
> after EVERY change to the file. The controllers and views are  
> reloading just fine and not being cached. It’s just the custom class  
> I created that’s being cached.
> 
> Any ideas as to what I should try to get it to stop caching the class?

No, but I’m having the same issue. I don’t know that it’s  
server-determined, but for what it’s worth you can add lighttpd to the  
list of servers under which it happens 🙂

David

> > - Brent
> 
> * * *
> 
> Rails mailing list  
> removed\_email\_address@domain.invalid  
> [http://lists.rubyonrails.org/mailman/listinfo/rails](http://lists.rubyonrails.org/mailman/listinfo/rails)

–  
David A. Black (removed\_email\_address@domain.invalid)  
Ruby Power and Light, LLC ([http://www.rubypowerandlight.com](http://www.rubypowerandlight.com))

“Ruby for Rails” chapters now available  
from Manning Early Access Program! [Ruby for Rails](http://www.manning.com/books/black)

---

<div class="post-metadata">

**Author:** ![Brent\_J](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/ccd318/32.png) [@Brent\_J](https://www.ruby-forum.com/u/Brent_J)\
**Post date:** [March 22, 2006, 3:38pm UTC](https://www.ruby-forum.com/t/class-caching-problem-was-newbie-question-about-custom-clas/85312/3 "2006-03-22T15:38:24Z")

</div>

> No, but I’m having the same issue. I don’t know that it’s  
> server-determined, but for what it’s worth you can add lighttpd to the  
> list of servers under which it happens 🙂
> 
> David

Shew, at least I know I’m not losing my mind then! I’ve grepped for  
all occurences of the word “cach” to see if there’s any other file  
which caching parameters and I’ve found nothing other than whats in  
the environments directory.

Thanks for letting me know I’m not the only one!

- Brent

---

<div class="post-metadata">

**Author:** ![Brent\_J](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/ccd318/32.png) [@Brent\_J](https://www.ruby-forum.com/u/Brent_J)\
**Post date:** [March 22, 2006, 3:51pm UTC](https://www.ruby-forum.com/t/class-caching-problem-was-newbie-question-about-custom-clas/85312/4 "2006-03-22T15:51:47Z")

</div>

Brent,

I may be missing old history on this thread so sorry if I’m asking a  
question that you’ve already covered:

you say “custom class”. Does your class inherit from  
ActiveRecord::Base?

If not, and if you’re using Rails1.0 you won’t easily get class  
reloading.

In edge-rails (and the upcoming Rails 1.1) there is a module-mixin  
called “Reloadable” that will allow you to mark arbitrary classes as  
reloadable so long as they conform to some file naming conventions.

## HTH, Trevor

Trevor S.  
[http://somethinglearned.com](http://somethinglearned.com)

---

<div class="post-metadata">

**Author:** ![Brent\_J](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/ccd318/32.png) [@Brent\_J](https://www.ruby-forum.com/u/Brent_J)\
**Post date:** [March 22, 2006, 4:07pm UTC](https://www.ruby-forum.com/t/class-caching-problem-was-newbie-question-about-custom-clas/85312/5 "2006-03-22T16:07:05Z")

</div>

Aha! You’re correct, the class does not inherit from  
ActiveRecord::Base. I am indeed using Rails 1.0, so I bet that’s the  
problem.

Thanks for filling me in!

- Brent

---

<div class="post-metadata">

**Author:** ![Brent\_J](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/ccd318/32.png) [@Brent\_J](https://www.ruby-forum.com/u/Brent_J)\
**Post date:** [March 22, 2006, 4:35pm UTC](https://www.ruby-forum.com/t/class-caching-problem-was-newbie-question-about-custom-clas/85312/6 "2006-03-22T16:35:50Z")

</div>

On Mar 22, 2006, at 10:06 AM, Brent J. wrote:

> Aha! You’re correct, the class does not inherit from  
> ActiveRecord::Base. I am indeed using Rails 1.0, so I bet that’s the  
> problem.

I got around this by using ‘require\_dependency’ rather than ‘require’  
when requiring the file with the custom classes. Seems to work fine  
for most situations. Apparently this will be replaced in 1.1 with a  
mixin.

> > HTH,
> > 
> > > being
> > > 
> > > > Thanks,  
> > > > [http://lists.rubyonrails.org/mailman/listinfo/rails](http://lists.rubyonrails.org/mailman/listinfo/rails)
> 
> * * *
> 
> Rails mailing list  
> removed\_email\_address@domain.invalid  
> [http://lists.rubyonrails.org/mailman/listinfo/rails](http://lists.rubyonrails.org/mailman/listinfo/rails)

* * *

Bob H. – blogs at \<[http://www.recursive.ca/](http://www.recursive.ca/)  
hutch/\>  
Recursive Design Inc. – [http://www.recursive.ca/](http://www.recursive.ca/)  
Raconteur – [http://www.raconteur.info/](http://www.raconteur.info/)  
xampl for Ruby – [http://rubyforge.org/projects/xampl/](http://rubyforge.org/projects/xampl/)
