簡體   English   中英

ActionMailer不發送電子郵件,在模型中傳遞值

[英]ActionMailer not sending emails, pass value in model

我正在使用郵箱發送郵件通知,如果這樣做:

def mailboxer_email(object)
  return "me@gmail.com"
end

它工作正常,但是我試圖返回用戶的電子郵件,並且我嘗試了以下操作:

def mailboxer_email(object)
  return "#{User.email}"    
end

我收到錯誤:

NoMethodError (undefined method `email' for #<Class:0x0000000402c138>):

當我嘗試這個:

def mailboxer_email(object)
  return :email
end

日志讀取

"sent mail to email"

我也試過

def mailboxer_email(object) 
  return object.email     
end

但是給我

NoMethodError (undefined method `email' for #<Message:0x000000039f0530>): 

這種方法解決了它,它只是通過不帶“:”的電子郵件

def mailboxer_email(object)
  return email  # instead of return :email
end

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM