为什么这个方法产生一个空变量,因此是空体?
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
虽然这种方法有效:
mail to: email, subject: "Name || #{subject}", body: message
答案 0 :(得分:1)
写这个
default from: "Name <name@domain.com>"
def custom_email(email, subject, message)
@message = message
mail to: email, subject: "Name || #{subject}"
end
而不是
default from: "Name <name@domain.com>"
def custom_email(email, subject, message)
mail to: email, subject: "Name || #{subject}"
@message = message
end
然后会考虑@message