Published by Dan Cunning on Mar 4, 2015

views/mailers directory

Avoid cluttering up app/views by moving mailer directories underneath a single parent.

Filed under Design

app/views contains both controller and mailer directories and becomes cluttered as your application grows. I keep app/views better organized by moving all my *_mailer directories underneath app/views/mailers, which is accomplished with one line of code:

# app/mailers/application_mailer.rb
class ApplicationMailer < ActionMailer::Base
  default template_path: ->(e) { "mailers/#{e.class.name.underscore}" }
end

Now UsersMailer templates go into app/views/mailers/users_mailer.

It just feels better this way.