Topic: ActionMailer

ActionMailer Callbacks: In the Spirit of ActionController Filters

One of the most useful features of ActionController is the ability to add filters before, after, or around actions.  This tool is made even more powerful by the ability to chain filters together.  Allowing an AOP approach is indispensable for addressing cross cutting concerns (or simply separating concerns), and is one of the things which makes a framework valuable to a developer (Spring is an excellent example of this).

A while back, I had a requirement to persist a record of which email addresses were sent an email through the system.  I expected to find callback support for ActionMailer, but was surprised to find that it didn't exist.

I had three options: put the logic inline in each ActionMailer method which is not DRY and muddles concerns, put the logic in the ActionContoller as filters which break encapsulation in terrible ways (and is at the wrong layer), or extend ActionMailler to allow callback methods.

I choose the latter...

Continue reading »

Launch: Pathfinder Newsletter

    Get a monthly update on best practices for delivering successful software.

    Subscribe via email


    Subscribe via RSS      RSS icon

Topics

Search

WordPress

Comments about this site: info@pathf.com