How to add Cloudinary files as email attachments in Action Mailer Ruby
Hi,
I'm using rails 6.0.3.4 and need to send emails automatically at the updating of my ArtistsMetric instance that
has_many_attached :justification_files
Here is my code in the ApplicationMailer:
def artists_metric_verification_files
@artists_metric = params[:artists_metric]
mail(to:(to: "dontspam@me.com", subject: "<%= @artists_metric.artist.name %> infos updated at <%= @artists_metric.updated_at %> ")
And in artists_metric_verification_files.html.erb:
<%= @artists_metric.artist.name %>
<%= cl_image_tag(@artists_metric.justification_files.each { |file| file, flags: "attachment"}) %>
My error is:
Encountered a syntax error while rendering template: check <%= @artists_metric.artist.name %> <%= cl_image_tag(@artists_metric.justification_files.each { |file| file, flags: "attachment"}) %>
By the way, I have tried to use the ancient syntax, but it doesn't work neither(same syntax error but with the "=>":
<%= cl_image_tag(@artists_metric.justification_files.each { |file| file, :flags => "attachment"}) %>
Would you please help me? I'm pretty sure it is a very simple change but I can't find the answer...
-
I am also facing same issue and don't know what to do.
-
Did anyone tried Daniel suggestion.
-
Some else tried his suggestions.
-
Hi @Resi,
I have tried to follow the instructions provided above but I didn't succeed. I think the post doesn't contain full details of information that I need.
-
Hi @MichaelWik,
In order to get a better understanding of the implementation that you would like to achieve, can you please help to open a support ticket here (https://support.cloudinary.com/hc/en-us/requests/new) and provide us the sample source code showing the errors you are encountering (e.g., through Github or Replit would be helpful)?
Thanks.
Please sign in to leave a comment.
Comments
9 comments