Hey Inaki thanks,

I think I'll have to go that way. I wonder if that is how rails does to 
load classes when the server is initialize. I wandered around the 
initializer file but couldn't get how it was done. Thanks again,

Elias

Iñaki Baz Castillo wrote:
> El Viernes 03 Abril 2009, Elias Orozco escribió:
>> >
>> > Dir.chdir(path)
>> > Dir["*.rb"].each do |file|
>> >         require "#{path}/#{file}"
>> > end
>>
>> Thanks Inaki, but in that example I will have to specify the require
>> files and that's exactly what I don't want. A lot of classes will be
>> copied into that folder and I can't hard-code all those requires.
> 
> When failing due to a non existing class, Ruby raises a NameError 
> exception.
> Then you can add something as:
> 
> ---------------------------
> failed_files=[]
> 
> path = xxxxxx
> Dir.chdir(path)
> 
> Dir["*.rb"].each do |file|
>   begin
>     require "#{path}/#{file}"
>   rescue NameError
>     failed_files << file
>   end
> end
> 
> failed_files.each do |file|
>   require "#{path}/#{file}"
> end
> ----------------------------
> 
> (It should be very improved however).

-- 
Posted via http://www.ruby-forum.com/.