dedicated mailer directory for 1.2

Any reason why ActionMailers go in Models rather than, say, Mailers? (since they aren't really at the 'database' part of the app, typically...)

court3nay wrote:

Any reason why ActionMailers go in Models rather than, say, Mailers? (since they aren't really at the 'database' part of the app, typically...)

I think it's mostly because "mailers" isn't one of the directories that is looked at by default, but that's a sad excuse. I'd love to see mailers go in their own directory.

- Jamis

At the very least, if you want to stick to the MVC nomenclature, they sound more like controllers. So they could go into the controllers dir. I think just having the file called whatever_mailer, rather then whatever_controller, would prevent rails from trying to load them as actual controllers.

Having said that, having a mailers dir sounds like a better idea, so +1.

(and how about sweepers?)

You could equally argue that observers should have their own directory as well.

-Jonathan.

Indeed, so that's mailers, observers, sweepers.

Everyone uses controllers and models, but not necessarily the items above. So I suggest that these directories should not exist in the default app, but be created by their respective generators if necessary.

I'm not sure how that affects rails's load path. Is it a problem to add inexistent dirs? I suspect not.

On a sidenote, there's no generator for sweepers. I guess a note could be added to the docs if we do come to the conclusion that separate dirs for each thing is the best way to go.

> You could equally argue that observers should have their own
> directory as well.

Mailers I can buy, everyone uses them and they have a distinct,
separate function. Sending email.

But observers, and sweepers are really just there to aid the operation
of something else.

config.autoload_paths += %W( #{RAILS_ROOT}/app/cachers )

I picked up app/cachers from i2 a long time ago, no idea why I still
use it. But, its good enough for me.

I meant that if we decide to standardize the dirs, we'd probably want to have them on the loadpath from the start, rather than have the developer add them later.

Personally I think observers generally form part of your overall
domain model - I don't think its sensible to restrict your model to
ActiveRecord objects; thats just not realistic. The model dir should
be for all components of your domain model.

Mailers on the other hand, I feel are part of the infrastructure
layer and I've always felt it a bit strange to stick them in the
models directory, so +1 for a dedicated mailers directory.

Cheers
Luke

Personally I think observers generally form part of your overall
domain model - I don't think its sensible to restrict your model to
ActiveRecord objects; thats just not realistic. The model dir should
be for all components of your domain model.

Agreed; your domain model doesn't necessarily have anything to do with
AR. However, observers are there to support your domain model, so
they belong in the same place...

Mailers on the other hand, I feel are part of the infrastructure
layer and I've always felt it a bit strange to stick them in the
models directory, so +1 for a dedicated mailers directory.

This has always concerned me, too, and anyone whom I've taught to use
Rails has wondered about the placement of mailers in the models
directory. They're not really part of the domain model, like Luke
mentioned, and I think merit their own directory. +1

Dave