0

Why is it that this method produces an empty variable and therefore empty body?

custom_email.text.erb

<%=@message%>

user_mailer.rb

default from: "Name <name@domain.com>"
def custom_email(email, subject, message)
  mail to: email, subject: "Name || #{subject}"
  @message = message
end

While this method works:

mail to: email, subject: "Name || #{subject}", body: message
4

1 回答 1

1

write this

default from: "Name <name@domain.com>"
def custom_email(email, subject, message)
  @message = message
  mail to: email, subject: "Name || #{subject}"
end

instead of

default from: "Name <name@domain.com>"
def custom_email(email, subject, message)
  mail to: email, subject: "Name || #{subject}"
  @message = message
end

then it will consider @message

于 2013-06-11T10:51:45.700 回答