DRY Up Lots o' Mailers

I have a heap of
fill-out-form/send-website-operator-mail/send-user-confirmation types of
forms. It’s daunting when you think about how many files it takes to do
this. I’m not coming up with an obvious “Rails” way to pull it off, so I
thought it’d be good to know if anyone else has worked through this (7
per
form!).

models/
my_form_data.rb
my_form_data_mailer.rb

controllers/
my_form_controller.rb

views/
my_form/
index.rhtml
show.rhtml
my_form_data_mailer/
sent.rhtml
confirm.rhtml

I’ll concede that I have to write this code once, but once for each
form? So
the notion begins to occur to me… Hmmmm, maybe there’s a way to make a
factory or some other usage pattern for these because the real things
that
change are the data model and the views.

As I said, I haven’t found anything that says “aha! that’s what’s going
to
be maintainable.” Where I’m at right now is to have a
LotsOfMailersController that contains a method for each mailer. The
models
and views still have to remain. I’ve refactored some of the repetitive
code
involved in wiring up the mailer into a protected method.

Any other hints? (I just can’t help thinking there’s some cool Rubyism
for
doing this :slight_smile:

View this message in context:
http://www.nabble.com/DRY-Up-Lots-o'-Mailers-t1765204.html#a4804773
Sent from the RubyOnRails Users forum at Nabble.com.