Tech Thoughts

Organizing Rails Code

Where do you keep separate classes for domain logic when you want to develop an object-oriented web app?

If you want to develop an object-oriented web app, then you'll find that only working with models, views, and controllers won't cut it. You'll need some separate classes for domain logic. But where do you keep those?

The answer is simple: just put them in app/lib/.

Don't worry about creating a plethora of sub-directories and rules for them. Just write OO code and put it in app/lib/. If a pattern emerges — like form or view objects — then you can always create a directory for it. In the meanwhile your classes will be easy to find, and you won't have to search through a bunch of directories with less than 3 files in them.