Where should I put helper objects?

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!

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

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
509-577-7732
[email protected]

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
[email protected]
http://lists.rubyonrails.org/mailman/listinfo/rails

Trevor S.
http://somethinglearned.com