# Where should I put helper objects?

**URL:** <https://www.ruby-forum.com/t/where-should-i-put-helper-objects/49601>\
**Category:** Rails\
**Created:** [December 6, 2005, 7:59pm UTC](https://www.ruby-forum.com/t/where-should-i-put-helper-objects/49601 "2005-12-06T19:59:38Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![KSSSSre](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/ebca7d/32.png) [@KSSSSre](https://www.ruby-forum.com/u/KSSSSre)\
**Post date:** [December 6, 2005, 7:59pm UTC](https://www.ruby-forum.com/t/where-should-i-put-helper-objects/49601/1 "2005-12-06T19:59:38Z")

</div>

Hi,

Sorry for a very basic question, but…

Where should I put objects and libraries I develop and share among the  
controllers? I tried to put them in the lib directory, but then I need  
to restart the server each time I make a change to the object because of  
caching.

So, is there a better place to put them?

Thanks!

---

<div class="post-metadata">

**Author:** ![KSSSSre](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/ebca7d/32.png) [@KSSSSre](https://www.ruby-forum.com/u/KSSSSre)\
**Post date:** [December 6, 2005, 8:32pm UTC](https://www.ruby-forum.com/t/where-should-i-put-helper-objects/49601/2 "2005-12-06T20:32:57Z")

</div>

On Tue, 2005-12-06 at 19:59 +0100, KÃ¥re wrote:

> Thanks!

I believe if you manually require it as a dependency, it will reload it  
when the file changes. I think the right spot for this require is in  
environment.rb?

require\_dependency ‘foo’

Either that, or figure out what structure you need to make a plugin out  
of it and stick it in vendor. I think the purpose for /lib is any 3rd  
party ruby modules that are unlikely to change (3rd party rails modules  
being either plugins or engines, going in /vendor).

- Jamie

---

<div class="post-metadata">

**Author:** ![KSSSSre](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/ebca7d/32.png) [@KSSSSre](https://www.ruby-forum.com/u/KSSSSre)\
**Post date:** [December 6, 2005, 9:17pm UTC](https://www.ruby-forum.com/t/where-should-i-put-helper-objects/49601/3 "2005-12-06T21:17:54Z")

</div>

On Dec 6, 2005, at 11:30 AM, Jamie M. wrote:

> > because of  
> > environment.rb?
> 
> - Jamie  
> require\_dependency is the right way to go but it unfortunately wont  
> work in the environment.rb since that file is only loaded once on  
> startup. So you might want to put the require\_dependency in your  
> application.rb for development mode so that it reloads on each  
> request. then once its tested and ready for the world you can require  
> it in environment.rb for production.

Cheers-  
-Ezra Z.  
Yakima Herald-Republic  
WebMaster  
[http://yakimaherald.com](http://yakimaherald.com)  
509-577-7732  
removed\_email\_address@domain.invalid

---

<div class="post-metadata">

**Author:** ![KSSSSre](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/ebca7d/32.png) [@KSSSSre](https://www.ruby-forum.com/u/KSSSSre)\
**Post date:** [December 6, 2005, 9:21pm UTC](https://www.ruby-forum.com/t/where-should-i-put-helper-objects/49601/4 "2005-12-06T21:21:58Z")

</div>

If the files in lib are to be used by your controllers then you put  
the require\_dependency call in your controllers/application.rb file  
(or whatever controller is using the lib).

I’m fairly certain that if you put the require\_dependency in your  
environment.rb file it will only be evaluated once (at boot time).  
Sticking it in your controllers/application.rb file will ensure it’s  
evaluated for each request (in development mode) so it will pick up  
your changes.

Regards,  
Trevor

On 6-Dec-05, at 11:30 AM, Jamie M. wrote:

> > because of  
> > environment.rb?
> 
> - Jamie
> 
> * * *
> 
> Rails mailing list  
> removed\_email\_address@domain.invalid  
> [http://lists.rubyonrails.org/mailman/listinfo/rails](http://lists.rubyonrails.org/mailman/listinfo/rails)

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