I’m working on a small project with a friend, and one of the things we
needed to do was send off an email whenever someone signs up an
account. His implementation was pretty simple - throw a
deliver_welcome call inside the controller after the signup. I’m sure
that this is a pretty common thing to do.
The problem, in my mind, was that the app now became tied to two
places - the controller and model - for handling business logic. What
do I mean? Well if I open script/console and do
Then no email is sent. According to our business rules, a welcome
email should be delivered whenever an account is registered. With his
implementation, the only way to correctly register an account is to do
it through the controller.
So what do you guys think about this? In my opinion I should only
have to type one command in console to make everything happen
(Account.register), and the controller should call the exact same
code, and only set up page info, error messages, etc.
One thing I’d like to point out is that if I send the email from
within Account.register, now the Account class gets tied to
ActionMailer and ActionPack. That seems pretty crappy too, really,
and I actually posted about that maybe a month ago. My solution was
to create a new Message model and have a separate app occasionally
poll the db to mail out messages, using the account_id to build the
To boil it down, do you think you should be able to manage your
application 100% through your domain model if you so desire?