Can I put seperate models into different directories

I have alot of models that are all linked. They are cluttering up my
app/models directory. Is it possible to move some of my models into a
sub directory. (i.e. app/models/items) Will Rails still pick these up?
Do I need to change any configuration settings?

Thanks in advance

Iain A.

On 8 Jul 2008, at 17:51, Iain A. wrote:

I have alot of models that are all linked. They are cluttering up my
app/models directory. Is it possible to move some of my models into a
sub directory. (i.e. app/models/items) Will Rails still pick these up?
Do I need to change any configuration settings?

see
http://blog.hasmanythrough.com/2008/5/6/a-simple-alternative-to-namespaced-models

Fred

Mr. Cheung,
I’ve tried all many of accomplishing of splitting my many models into
subdirectories as displayed in the link you provide and one other.
Each time I get an error message such as;

LoadError in Evidence/dispcodesController#index
Expected D:/Rails/itracker/app/models/evidence/dispcode.rb to define
Evidence::Dispcode

The two approaches I’ve tried are;

  1. config.load_paths += %W( #{RAILS_ROOT}/app/models/evidence) =
    Josh’s approach
  2. Dir.glob(“#{RAILS_ROOT}/app/models/**/*”).each {|d|
    config.load_paths << d if File.directory?(d) }
    I wouldl be thrilled to make this work for all of the reaons that Josh
    explained. Note that all of the controllers are in sub folders to
    reflect their function.
    Thank you,
    Kathleen

On Jul 8, 10:56 am, Frederick C. [email protected]

Frederick C. wrote:

see
has_many :through - A simple alternative to namespaced models

Fred

I’m sure someone blogged about that way before him…

albeit a horrible looking, poorly maintained, blogger blog.