我正在尝试使用Mail gem和ERB gem发送电子邮件,但是我一直在收到此错误TypeError Exception: no implicit conversion of Hash into Integer
我阅读了Mail Gem文档和ERB文档,但我按照他们的指示进行操作,但不起作用。
这是方法,email
是目的地,errors
是一个数组,其中包含可能发生的可能的错误(如果没有任何问题,则为空)
def self.send_file(email, errors)
@errors = errors
if errors.any?
subject = 'There has been an error'
template = %(
<html>
<p>Sorry, these errors occured:</p>
<ul>
<% @errors.each do |error| %>
<li><%= error %></li>
<% end %>
</ul>
</html>
).gsub(/^ {2}/, '')
else
subject = 'Everything is okey'
template = %(
<html>
<p> Everything it's okay! </p>
</html>
).gsub(/^ {2}/, '')
end
message = ERB.new(template, trim_mode: '<%>')
@errors = errors
mail = Mail.new do
from ENV['NOTIFICATIONS_EMAIL']
to email
subject subject
html_part do
content_type 'text/html; charset=UTF-8'
body message.run(binding)
end
end
mail.deliver
end
有人知道发生了什么事吗?