I'm trying to send an email using the Mail gem and the ERB gem but I'm getting all the time the this error TypeError Exception: no implicit conversion of Hash into Integer
I read the Mail Gem documentation and the ERB Documentation, and I followed their instructions but it is not working.
This is the method, email
is the destination, and errors
is an Array that contains possible errors that may have occurred (is empty if there were not any problems)
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
Does anyone know what is going on?