# Model reloading problem

**URL:** <https://www.ruby-forum.com/t/model-reloading-problem/56439>\
**Category:** Rails\
**Created:** [March 31, 2006, 7:04am UTC](https://www.ruby-forum.com/t/model-reloading-problem/56439 "2006-03-31T07:04:34Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Luciano\_B](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/8edcca/32.png) [@Luciano\_B](https://www.ruby-forum.com/u/Luciano_B)\
**Post date:** [March 31, 2006, 7:04am UTC](https://www.ruby-forum.com/t/model-reloading-problem/56439/1 "2006-03-31T07:04:34Z")

</div>

Hi all,

I’ve a model class Toto in the model directory.

I don’t understand why i have to restarts WebBrick to view changes i  
make  
in this class

FYI : in the development. rb i desabled class cache with

config.cache\_classes = false

Regards

Luciano

---

<div class="post-metadata">

**Author:** ![Luciano\_B](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/8edcca/32.png) [@Luciano\_B](https://www.ruby-forum.com/u/Luciano_B)\
**Post date:** [March 31, 2006, 8:01am UTC](https://www.ruby-forum.com/t/model-reloading-problem/56439/2 "2006-03-31T08:01:39Z")

</div>

Luciano B. wrote:

> Hi all,
> 
> I’ve a model class Toto in the model directory.
> 
> I don’t understand why i have to restarts WebBrick to view changes i  
> make  
> in this class
> 
> FYI : in the development. rb i desabled class cache with
> 
> config.cache\_classes = false

I believe you may have just answered your own question. 🙂

Alan

---

<div class="post-metadata">

**Author:** ![Luciano\_B](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/8edcca/32.png) [@Luciano\_B](https://www.ruby-forum.com/u/Luciano_B)\
**Post date:** [March 31, 2006, 8:20am UTC](https://www.ruby-forum.com/t/model-reloading-problem/56439/3 "2006-03-31T08:20:24Z")

</div>

Thx for your response

But my environement file include

config.cache\_classes = false

This force reloading no ???

but the class is not reloaded unless i restart webbrick .

Have you an other idea

Thanks by advance

On 3/31/06, Alan F. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> > FYI : in the development. rb i desabled class cache with  
> > Rails mailing list  
> > removed\_email\_address@domain.invalid  
> > [http://lists.rubyonrails.org/mailman/listinfo/rails](http://lists.rubyonrails.org/mailman/listinfo/rails)

## –

Luciano B.

email: removed\_email\_address@domain.invalid  
TÃ©l: 06 61 84 51 00  
Fax: 04 92 72 65 91

---

<div class="post-metadata">

**Author:** ![Luciano\_B](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/8edcca/32.png) [@Luciano\_B](https://www.ruby-forum.com/u/Luciano_B)\
**Post date:** [March 31, 2006, 8:48am UTC](https://www.ruby-forum.com/t/model-reloading-problem/56439/4 "2006-03-31T08:48:21Z")

</div>

Hi,

does your model inherit from ActiveRecord::Base? If it doesn’t then  
it won’t get reloaded automatically and you’ll have to do a little  
extra work:

In rails 1.0 you can put this into your app/controllers/  
application.rb file:

require\_dependency ‘toto’

And in rails 1.1 you can use the Reloadable mixin. So in app/models/  
toto.rb you have:

class Toto  
include Reloadable

# the rest of your stuff here

end

## HTH, Trevor

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

---

<div class="post-metadata">

**Author:** ![Luciano\_B](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/8edcca/32.png) [@Luciano\_B](https://www.ruby-forum.com/u/Luciano_B)\
**Post date:** [March 31, 2006, 11:19pm UTC](https://www.ruby-forum.com/t/model-reloading-problem/56439/5 "2006-03-31T23:19:03Z")

</div>

Luciano B. wrote:

> Thx for your response
> 
> But my environement file include
> 
> config.cache\_classes = false

Doh! Apologies for a head full of mince.

Alan

---

<div class="post-metadata">

**Author:** ![Luciano\_B](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/8edcca/32.png) [@Luciano\_B](https://www.ruby-forum.com/u/Luciano_B)\
**Post date:** [March 31, 2006, 9:50am UTC](https://www.ruby-forum.com/t/model-reloading-problem/56439/6 "2006-03-31T09:50:10Z")

</div>

Many thanks, it works.

Thank you Trevor

On 3/31/06, Trevor S. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> require\_dependency ‘toto’  
> Trevor
> 
> > I’ve a model class Toto in the model directory.
> 
> [http://lists.rubyonrails.org/mailman/listinfo/rails](http://lists.rubyonrails.org/mailman/listinfo/rails)

## –

Luciano B.

email: removed\_email\_address@domain.invalid  
TÃ©l: 06 61 84 51 00  
Fax: 04 92 72 65 91
