Discover more from Boring Rails
Writing better Action Mailers: revisiting a core Rails concept
Mailers are used in literally every Rails application, but often an after thought where we throw out the rules of software design. Revisiting the tools provided by Action Mailer can help us improve!
Mailers are a feature used in literally every Rails application. But they are often an after thought where we throw out the rules of well-written applications.
Writing mailers is a "set it and forget it" part of your codebase. But recently, I've revisited the handful of mailers in my application and I was shocked at both how bad things were and also how many nice mailer features in Rails I wasn't aware of.
I've been writing Rails applications for over 10 years and there were things I figured out just this week about mailers that I will be using as my new defaults going forward.
Better display names for “From” field
Changing the folder structure for mailer views
Avoid adding “_email” to everything
Parameterized mailers (aka I’ve been doing Mailers wrong…)
Dynamic default values
Organizing by app-specific contexts
👉 Read it here: Writing better Action Mailers
📣 Thoughts? Join the discussion on Twitter