关注Sending Email with Phoenix文档。有错误
Phoenix.Template.UndefinedError)无法为MyApp.EmailView呈现“welcome.html”,请为render / 2定义匹配子句或在“lib / MyApp / web / templates”中定义模板。没有为此模块编译模板
我在welcome.html
中有/templates/email
。如果我在welcome.html
中有/templates
,我就不会遇到这个问题。
...以及带错误的函数
#lib/Myapp/web/email.ex
defmodule MyApp.Email do
use Bamboo.Phoenix, view: MyApp.EmailView
def welcome_text_email(email_address) do
new_email()
|> to(email_address)
|> from("example@example.com")
|> subject("Welcome!")
|> put_html_layout({MyApp.Web.LayoutView, "email.html"})
|> render("welcome.html",email_address: email_address)
end
#lib/Myapp/web/views/email_view.ex
defmodule MyApp.EmailView do
use MyApp.Web, :view
end