어떤 이유인지이 인스턴스의 변수가이 ActionMailer에 설정되어 있지 않습니다. 다른 ActionMailers는 정상적으로 작동하는 것 같습니다. 어떤 아이디어가이 원인 일 수 있습니까? UserMailer는 제한된 단어 perpahps입니까?내 인스턴스 변수가 내 조치 메일러보기에서 설정되지 않는 이유는 무엇입니까?
return unless user and user.email and not user.confirmed_at
이메일을 전송 중단하지 않았다 :
사용 레일
# app/mailers/user_mailer.rb
class UserMailer < ActionMailer::Base
default from: 'My Name <[email protected]>'
def registration_confirmation(user)
# Don't send email if we don't have an email address to send it to or the user is already confirmed
return unless user and user.email and not user.confirmed_at
# Set global variable for mail view
@my_message = 'Hello world!'
# Send email
mail(to: "#{user.name} <#{user.email}>", subject: 'Please confirm your email address')
end
end
# app/views/user_mailer/registration_confirmation.text.erb
Hello who? <%= @my_message %> # Simply returns 'Hello who? '