Skip to content

Rails 5 + Mailer: MissingTemplate Error #65

@jonbcampos

Description

@jonbcampos

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions