Model and controller namespace/structure


#1

Hi all -

I have a large project that has about 100 tables in the database that
we want to test porting to Rails. My main issue right now is that
although I can tell rails to do something like:
generate model Review::UserReview
and
generate controller Review::UserReview

and rails will write out the correct directory packaging, all my unit
tests break because of their dependency on loading test_helper in the
directory immediately above “unit”.

I played around with trying to tell ruby where the correct files are
but each iteration broke some other chunk of code somewhere and I
thought I’d check here first.

Basically I want to have 5 or 6 top level directories under models and
controllers and views so that I can organize these 75 or so files.
It’s very tedious to work in a directory of that many unrelated files.

Thanks for any tips or help. I’m new to Ruby and Rails and this
aspect or ROR is the most difficult to wrap my head around for some
reason - probably because I’m coming at this from the strict java
packagind world.

Best Regards
Mike


#2

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Nov 22, 2005, at 7:24 AM, Michael E. wrote:

and rails will write out the correct directory packaging, all my unit
tests break because of their dependency on loading test_helper in the
directory immediately above “unit”.

This is a bug in the model generator. The controller and scaffold
generators make the correct relative path to test_helper. The model
generator bug is fixed in 1.0.

Basically I want to have 5 or 6 top level directories under models and
controllers and views so that I can organize these 75 or so files.
It’s very tedious to work in a directory of that many unrelated files.

Definitely; organization helps.

Thanks for any tips or help. I’m new to Ruby and Rails and this
aspect or ROR is the most difficult to wrap my head around for some
reason - probably because I’m coming at this from the strict java
packagind world.

There convention is that

foo/bar/baz.rb

contains

module Foo
module Bar
class Baz
end
end
end

though it is not strict. You can do what you like.

Best,
jeremy
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2 (Darwin)

iD8DBQFDg43XAQHALep9HFYRAkF7AKCBVeNBgSl3+CFYbNFaxA5uUtbNzgCgooWF
5SR5N6kItka1/wxw0akdSuc=
=eQDi
-----END PGP SIGNATURE-----