caxlsx_rails: Rails 5 + Mailer: MissingTemplate Error

I know this is showing up in other issues but, maybe I’m missing something, but in my tests I’m still getting an error:

Minitest::UnexpectedError: ActionView::MissingTemplate: Missing template layouts/mailer with {:locale=>[:en], :formats=>[:xlsx], :variants=>[], :handlers=>[:axlsx]}. Searched in:
  * "/Users/myuser/Documents/code/myapp/app/views"
  * "/Users/myuser/.rvm/gems/ruby-2.3.1/gems/pghero-1.6.2/app/views"
  * "/Users/myuser/.rvm/gems/ruby-2.3.1/gems/resque-web-0.0.9/app/views"
  * "/Users/myuser/.rvm/gems/ruby-2.3.1/gems/twitter-bootstrap-rails-3.2.2/app/views"
  * "/Users/myuser/.rvm/gems/ruby-2.3.1/gems/devise_invitable-1.7.0/app/views"
  * "/Users/myuser/.rvm/gems/ruby-2.3.1/gems/devise-4.2.0/app/views"

My code for the mailer:

def batch_transfer_complete(batch_transfer_id)
    @batch_transfer                          = BatchTransfer.find(batch_transfer_id)
    admins                                   = Admin.pluck(:email)
    xlsx                                     = render_to_string 
                                                                handlers: [:axlsx],
                                                                formats:  [:xlsx],
                                                                template: 'batch_transfers/show',
                                                                locals:   { batch_transfer: @batch_transfer }
    attachments[@batch_transfer.to_filename] = { mime_type: Mime::XLSX, content: xlsx, encoding: 'base64' }
    mail to:      admins,
         subject: t('admin_mailer.batch_transfer_complete.subject', model: BatchTransfer.model_name.human.titleize)
  end

Any ideas of what I may be missing?

About this issue

Most upvoted comments

Old issue but here’s a fix:

mail(to: 'test@test.com', subject: "Export") do |f|
  f.text do
    render text: nil # In order to don't use a template
  end
end