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 2005-12-06 19:59
on 2005-12-06 20:32
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 2005-12-06 21:17
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. Cheers- -Ezra Zygmuntowicz Yakima Herald-Republic WebMaster http://yakimaherald.com 509-577-7732 firstname.lastname@example.org
on 2005-12-06 21:21
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 Macey wrote: >> because of > environment.rb? > - Jamie > > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails Trevor Squires http://somethinglearned.com