Forum: Ruby on Rails Where should I put helper objects?

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
KÃ¥re (Guest)
on 2005-12-06 19:59

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

So, is there a better place to put them?

D280c8fe86ab3e824020bef5b80199d3?d=identicon&s=25 Jamie M. (jamie)
on 2005-12-06 20:32
(Received via mailing list)
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

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
ezra (Guest)
on 2005-12-06 21:17
(Received via mailing list)
On Dec 6, 2005, at 11:30 AM, Jamie Macey 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.

-Ezra Zygmuntowicz
Yakima Herald-Republic
trevor (Guest)
on 2005-12-06 21:21
(Received via mailing list)
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.


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

>> because of
> environment.rb?
> - Jamie
> _______________________________________________
> Rails mailing list

Trevor Squires
This topic is locked and can not be replied to.