Я в среде разработки. При запуске электронной почты в пользовательском интерфейсе я получаю сообщение об ошибке в браузере:
No template for interactive request
Admins::AdminsController#testmail is missing a template for request formats: text/html
NOTE!
Unless told otherwise, Rails expects an action to render a template with the same name,
contained in a folder named after its controller. If this controller is an API responding with 204 (No Content),
which does not require a template, then this error will occur when trying to access it via browser,
since we expect an HTML template to be rendered for such requests. If that's the case, carry on.
Журнал показывает:
Started GET "/en/admins/1/testmail" for 127.0.0.1 at 2020-03-05 08:28:00 +0100
Processing by Admins::AdminsController#testmail as HTML
Parameters: {"locale"=>"en", "admin_id"=>"1"}
Rendering test_mailer/testmail.text.erb within layouts/mailer
Rendered test_mailer/testmail.text.erb within layouts/mailer (Duration: 0.1ms | Allocations: 4)
TestMailer#testmail: processed outbound mail in 2.0ms
Delivered mail 5e60aa00a74a7_20213ffce2ad423c8083a@domain.example.com.mail (59.0ms)
Date: Thu, 05 Mar 2020 08:28:00 +0100
From: admin@domain.com
To: me@example.com
Message-ID: <5e60aa00a74a7_20213ffce2ad423c8083a@domain.example.com.mail.mail>
Subject: Welcome to My Awesome Site
Mime-Version: 1.0
Content-Type: text/plain;
charset=UTF-8
Content-Transfer-Encoding: 7bit
Welcome to example.com
===============================================
You have successfully signed up to example.com,
your username is: XXXX
To login to the site, just follow this link: .
Thanks for joining and have a great day!
Completed 406 Not Acceptable in 64ms (ActiveRecord: 0.0ms | Allocations: 3862)
ActionController::MissingExactTemplate (Admins::AdminsController#testmail is missing a template for request formats: text/html):
actionpack (6.0.2.1) lib/action_controller/metal/implicit_render.rb:45:in `default_render'
actionpack (6.0.2.1) lib/action_controller/metal/basic_implicit_render.rb:6:in `block in send_action'
actionpack (6.0.2.1) lib/action_controller/metal/basic_implicit_render.rb:6:in `tap'
actionpack (6.0.2.1) lib/action_controller/metal/basic_implicit_render.rb:6:in `send_action'
actionpack (6.0.2.1) lib/abstract_controller/base.rb:196:in `process_action'
Выше видно, что шаблон отображается до появления ошибки.
Мой класс Mailer:
class TestMailer < ApplicationMailer
def testmail
mail(to: 'user@domain.com',
subject: 'Welcome to My Awesome Site') do |format|
format.text
end
end
end
Конечно, шаблон помещается в /app/views/test_mailer/testmail.text.erb
.
Конфигурация моего почтового сервера в development.rb:
У меня работает mailcatcher на локальном хосте
config.action_mailer.raise_delivery_errors = true
config.action_mailer.perform_caching = false
config.action_mailer.smtp_settings = {
address: 'localhost',
port: 1025
}
config.action_mailer.delivery_method :smtp
config.action_mailer.perform_deliveries = true
config.action_mailer.raise_delivery_errors = false
Я на Centos 7, никаких специальных символов и пробелов в весь путь приложения Rails Спасибо за ваши исследования.