In mcs_mailer.rb
:
def invite(email,subject,body,attachment_urls)
@attachment_urls= attachment_urls
mandrill_mail(
template: 'group-invite',
subject: subject,
to: email,
html: body,
attachments: [ @attachment_urls.each do |url|
{
content: File.read(url),
name: 'offer.pdf',
type: 'application/pdf'
}
end
])
I am using mandrill_mail
in my rails application.I want to send mail with multiple attachments. But getting error in the each loop undefined method
symbolize_keys!' for #
Try
Use map to return an array of each block return value.
You get this error because it tries to
symbolize_keys!
on the first value of:attachments
array, which is also an array (Array#each
returns the object itself when a block is provided).