I'm writing to an email table every-time my app receives emails.
I'm passing in an email object to create the record, but failing to figure out how to translate the email.to property, which is an array of hashes.
I have the corresponding EmailAddress has many model set up with the proper attributes to transfer over!
The Email model 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
An example of what I beleive the email.to would look like:
email.to = [{
:token => "A",
:email => "A2",
:full => "A3",
:name => "A4"
},{
:token => "B",
:email => "B2",
:full => "B3",
:name => "B4"
}]