From: Tietew Date: 2009-02-20T17:05:10+09:00 Subject: Re: load a path (not a file) On Fri, 20 Feb 2009 16:26:33 +0900 In article <200902200829.54268.stefano.crocco@alice.it> [Re: load a path (not a file)] Stefano Crocco wrote: > > I need to load a path not a file. I am trying this but it is not working > > > > load RAILS_ROOT+"/public/users/#{self.login}/lib/" It is NOT recommended to put ruby files under Rails "public" directory because their files can be shown by any web browsers in the world. > dir = RAILS_ROOT+"/public/users/#{self.login}/lib/" > Dir.entries(d).each do |f| > load File.join(d, f) if file.match(/\.rb$/) > end Dir.[] or Dir.glob is easier. Dir.glob("#{RAILS_ROOT}/public/users/#{self.login}/lib/*.rb").each { |f| load(f) } -- Tietew