Reputation: 1613
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 #
Upvotes: 0
Views: 596
Reputation: 12710
Try
# [...]
attachments: @attachment_urls.map do |url|
{
# [...]
}
end
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).
Upvotes: 1