Thoughts about Notifiers in Rails

rails notifiers conventions naming

12|09|2009

Most of the example or open source code built for rails I see usually use the class name Notifier for their mailer. I was peer-pressured into doing so also, but lately I've been thinking about this convention and stumbled on a possibly better naming.

Namespacing

./script/generate mailer notifiers/activation instructions confirmation

Then somewhere in your model you'd do something like

Notifiers::Activation.deliver_instructions( user )

which is definitely better than

Notifier::deliver_activation_instructions( user )

The drawback of putting all notifications in notifier is when you get like 10 or even 20 different deliveries.

Also in your views its

app/views/notifiers/activation/instructions
app/views/notifiers/activation/confirmation
...
app/views/notifiers/password/reset
app/views/notifiers/questions/response

rather than

app/views/notifier/activation_instructions
app/views/notifier/activation_confirmation
app/views/notifiers/password_reset
app/views/notifiers/question_response

You may argue that this seems like a small thing to ponder about, but I guess the point is, I care about the quality, readability, and maintainability of my code.

blog comments powered by Disqus