Correct location for ActionMailer interceptor

28 views
Skip to first unread message

Cody Skidmore

unread,
Jun 26, 2015, 10:51:23 AM6/26/15
to rubyonra...@googlegroups.com
I read the Rails documentation for creating an email interceptor. It mentions putting the registration in config/initializers, However, there's no mention about where I should store the interceptor itself. What is the best practice for this?
Message has been deleted

Cody Skidmore

unread,
Jun 27, 2015, 9:43:34 AM6/27/15
to rubyonra...@googlegroups.com
Thank you Elizabeth. I'm new to Rails so poking around in the Rails source is insightful. 

Usually the test case is a good guide for how to use a piece of code. The interceptor is declared right inside the test case. The documentation and the test seem to imply that I should declare the interceptor and the registration in the same file and place it inside the initializers folder.

I'm implementing an email interceptor that redirects outbound email to a testing email account during development, so I added an interceptors folder under config and put the registration in development.rb. This seems a sensible place for interceptors to live. It also registers the interceptor only under the right circumstance.

Feedback about this is appreciated, 

Reply all
Reply to author
Forward
0 new messages