Forum: Ruby on Rails automatically load subdirectories under app/models

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
661ae6e97d0e16c2af2aaf7d197e8387?d=identicon&s=25 Sijo k g (sijo)
on 2008-12-31 06:08
Hi
   I have found the the below code in environment.rb Here used
subdirectories to better organize files

Dependencies.load_paths += [
  File.join(RAILS_ROOT, "app/models/Dir1"), File.join(RAILS_ROOT,
"app/models/Dir2")
]

What I understood is Rails includes /app/models in the load_path
automatically however it does not include subdirectories. Is it right? I
would like to know there is a better way on handling that, either by
generically loading all subdirectories or by having 1 file in the
app/models directory load the files in the subdirectory

Thanks in advance
Sijo
00973881979aa0a660ffbbb2f7a907fb?d=identicon&s=25 Peter De Berdt (Guest)
on 2008-12-31 13:03
(Received via mailing list)
On 31 Dec 2008, at 06:08, Sijo Kg wrote:

> right? I
> would like to know there is a better way on handling that, either by
> generically loading all subdirectories or by having 1 file in the
> app/models directory load the files in the subdirectory

This would probably work:
config.load_paths += Dir["#{RAILS_ROOT}/app/models/**/**"]


Best regards

Peter De Berdt
661ae6e97d0e16c2af2aaf7d197e8387?d=identicon&s=25 Sijo k g (sijo)
on 2009-01-02 09:42
Hi
   Could you please tell here the difference between
config.load_paths += Dir["#{RAILS_ROOT}/app/models/**/**"]
and

config.load_paths += Dir["#{RAILS_ROOT}/app/models/**"]

        Note **

Sijo
00973881979aa0a660ffbbb2f7a907fb?d=identicon&s=25 Peter De Berdt (Guest)
on 2009-01-02 12:27
(Received via mailing list)
On 02 Jan 2009, at 09:42, Sijo Kg wrote:

>   Could you please tell here the difference between
> config.load_paths += Dir["#{RAILS_ROOT}/app/models/**/**"]

models and all subdirectories (even within a subdirectory)

> and
>
> config.load_paths += Dir["#{RAILS_ROOT}/app/models/**"]

models and subdirectories in models


Best regards

Peter De Berdt
661ae6e97d0e16c2af2aaf7d197e8387?d=identicon&s=25 Sijo k g (sijo)
on 2009-01-02 12:55
Hi
    Thanks
This topic is locked and can not be replied to.