每次我的应用程序收到电子邮件时,我都会写信给电子邮件表。
我正在传递一个电子邮件对象来创建记录,但无法弄清楚如何翻译 email.to 属性,这是一个哈希数组。
我有相应的 EmailAddress 有许多模型设置了适当的属性来转移!
电子邮件模型 has_many :email_addresses, class_name: "EmailAddress", as: "email_addressable"。
class EmailProcessor
def self.process(email)
Email.create!({
body: email.body,
subject: email.subject,
email_addresses: email.to
})
end
end
我相信 email.to 的示例如下:
email.to = [{
:token => "A",
:email => "A2",
:full => "A3",
:name => "A4"
},{
:token => "B",
:email => "B2",
:full => "B3",
:name => "B4"
}]