Published by Dan on Mar 4, 2015

views/mailers directory

Filed under Tips

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/#{}" }

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

Before and After

It just feels better this way.


© 2012-2019 Dan Cunning. All rights reserved.