I have a class that is hand-coded (not generated using generator). Is there a preferred location for the file. app/components ? does it matter? Thanks, -- Posted via http://www.ruby-forum.com/.
On Mon, May 01, 2006 at 11:46:43PM +0200, Pradeep Sethi wrote:> I have a class that is hand-coded (not generated using generator). > > Is there a preferred location for the file. > > app/components ? > > does it matter?Hey Pradeep, Not components. Put it in lib/. marcel -- Marcel Molina Jr. <marcel@vernix.org>
These things generally go in /lib. On 5/1/06, Pradeep Sethi <psethi@gmail.com> wrote:> > I have a class that is hand-coded (not generated using generator). > > Is there a preferred location for the file. > > app/components ? > > does it matter? > > > Thanks, > > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060501/4854a230/attachment.html
/lib I''m pretty sure. That''s where me puts ''em. Joe -- Posted via http://www.ruby-forum.com/.
You should put them in RAILS_ROOT/lib if they are app specific. If you plan to use them on multiple apps, consider writing a plugin. Note: code in /lib is loaded only once so unless you use require_dependency, you''ll have to restart the server when you make changes. Also, it''s good practice to wrap your code in a module to reduce the chance of a namespace collision. Pradeep Sethi wrote:> I have a class that is hand-coded (not generated using generator). > > Is there a preferred location for the file. > > app/components ? > > does it matter? > > > Thanks,-- Posted via http://www.ruby-forum.com/.
Just a follow-up question. I don''t see RAILS_ROOT/lib dir. does it suppose to exist by default or do I need to create it with the first class. Making sure, that I am looking at the right place. Thanks, Steve Ross wrote:> You should put them in RAILS_ROOT/lib if they are app specific. If you > plan to use them on multiple apps, consider writing a plugin. > > Note: code in /lib is loaded only once so unless you use > require_dependency, you''ll have to restart the server when you make > changes. Also, it''s good practice to wrap your code in a module to > reduce the chance of a namespace collision. > > > Pradeep Sethi wrote: >> I have a class that is hand-coded (not generated using generator). >> >> Is there a preferred location for the file. >> >> app/components ? >> >> does it matter? >> >> >> Thanks,-- Posted via http://www.ruby-forum.com/.
Pradeep Sethi wrote:> Just a follow-up question. > > I don''t see RAILS_ROOT/lib dir. does it suppose to exist by default or > do I need to create it with the first class. > > Making sure, that I am looking at the right place.RAILS_ROOT is a constant that identifies the root directory of your application. It is the directory that contains the app, config, log, public, script and vendor directories. It should also contain lib, assuming you created your application with rail, so you should not have to create it. -- Ray
Steve Ross wrote: > Note: code in /lib is loaded only once so unless you use > require_dependency, you''ll have to restart the server when you make > changes. To avoid having to restart the server, I just make them reloadable: # file: lib/foo.rb: class Foo include Reloadable ... end Alain