Compound model names

Hi,

I’ve a question about the use of compound names with my models
(separate models into modules).

I’m developing a big application for which my main models has a lot of
other referenced models via foreign keys, to reach a 3FN database
design.

I know that it’s possible to use something like Blog::Post as a model
name, and then put each model file into a subfolder. So I could create
a module called, for example, Blog, and then put there all the
submodels that are specific for the Blog module. This way I will have
a better organization of my project, instead of having a lot of files
at app/models. With Rails 1.2, it is necessary to add each subdir to
the load_path array on the configuration file, but this is ok.

Am I able to use the same model name in different modules? I mean, to
have for example two models called Post, one on a Blog module and the
other on the News module. How will relationships work then? Because if
I use has_many :posts on referenced models, how can Rails know that
I’m referring one Post model or the other? And the same for
map.resources macro on routes.rb. Is this possible, or I must use
different model names?

Thanks a lot!

Carlos P.

Carlos,

I’m wondering about all the ins-and-outs of nesting models too. Let me
know if you find an answer.

Is there anyone out there doing this who has already sorted through all
the pitfalls? It would be great to have a Wiki page with details.

Kevin