# Reload external lib

**URL:** <https://www.ruby-forum.com/t/reload-external-lib/78522>\
**Category:** Rails\
**Created:** [December 6, 2006, 4:01pm UTC](https://www.ruby-forum.com/t/reload-external-lib/78522 "2006-12-06T16:01:43Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![nuby2ruby](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/54ee81/32.png) [@nuby2ruby](https://www.ruby-forum.com/u/nuby2ruby)\
**Post date:** [December 6, 2006, 4:01pm UTC](https://www.ruby-forum.com/t/reload-external-lib/78522/1 "2006-12-06T16:01:43Z")

</div>

In development mode rails reloads all the controllers and models each  
time they are requested. Is it possible to make rails reload any other  
files, for example ones that I placed under the lib folder and require  
in environment.rb?

–

_Jeremy W._  
Serval Systems Ltd.

[www.servalsystems.co.uk](http://www.servalsystems.co.uk) [http://www.servalsystems.co.uk](http://www.servalsystems.co.uk)  
Tel: 01342 331940  
Fax: 01342 331950

---

<div class="post-metadata">

**Author:** ![nuby2ruby](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/54ee81/32.png) [@nuby2ruby](https://www.ruby-forum.com/u/nuby2ruby)\
**Post date:** [December 18, 2006, 1:31am UTC](https://www.ruby-forum.com/t/reload-external-lib/78522/2 "2006-12-18T01:31:44Z")

</div>

> In development mode rails reloads all the controllers and models each  
> time they are requested. Is it possible to make rails reload any other  
> files, for example ones that I placed under the lib folder and require  
> in environment.rb?

If anybody has a solution to this I too would be interested in  
knowing. Is the reload list configurable in any way at all?

If not where is the list so I can change it manually?

---

<div class="post-metadata">

**Author:** ![nuby2ruby](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/54ee81/32.png) [@nuby2ruby](https://www.ruby-forum.com/u/nuby2ruby)\
**Post date:** [December 18, 2006, 2:01am UTC](https://www.ruby-forum.com/t/reload-external-lib/78522/3 "2006-12-18T02:01:47Z")

</div>

On 12/18/06, Tim U. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> > In development mode rails reloads all the controllers and models each  
> > time they are requested. Is it possible to make rails reload any other  
> > files, for example ones that I placed under the lib folder and require  
> > in environment.rb?
> 
> If anybody has a solution to this I too would be interested in  
> knowing. Is the reload list configurable in any way at all?

You need to include Reloadable in the classes you want reloaded.

class Fred  
include Reloadable  
end

This will make Fred and all its subclasses reload on each request.  
There’s also include Reloadable::Subclasses.

class Base  
include Reloadable::Subclasses  
end

This makes subclasses of Base reload on each request, but not Base  
itself. (Used, for instance, by ActiveRecord::Base.)

You can also _prevent_ a class from being reloaded by making  
#reloadable? return false.

class MyThingy \< Base  
def self.reloadable?  
false  
end  
end

HTH.

---

<div class="post-metadata">

**Author:** ![nuby2ruby](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/54ee81/32.png) [@nuby2ruby](https://www.ruby-forum.com/u/nuby2ruby)\
**Post date:** [December 18, 2006, 2:07am UTC](https://www.ruby-forum.com/t/reload-external-lib/78522/4 "2006-12-18T02:07:47Z")

</div>

On Dec 6, 7:59 am, Jeremy W. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> In development mode rails reloads all the controllers and models each  
> time they are requested. Is it possible to make rails reload any other  
> files, for example ones that I placed under the lib folder and require  
> in environment.rb?

In Rails 1.1.6 you can put “include Reloadable” into your lib classes  
to make them reload (only works for classes, not modules). In Rails  
1.2 “include Reloadable” has been deprecated. My understanding is that  
class reloading has been improved making the explicit Reloadable  
declaration unnecessary.

Aaron
