Skip to main content
Ask A Question
You’re not receiving notifications from this thread.

Upload image and send email without saving to the database

Rails • Asked by Lee Terng Gio

I recently tried to implement summernote to my rails app. I can send email and everything works fine. But I want to upload image and send the email, but the email received shows that the image was broken. How do I fix it?

The email that attached with uploaded image doesn't need to be saved into database. I just want to send the email.

My mailer.rb
def message_send(candidate_mail)
@candidate_mail = candidate_mail
to: "#{}",
from: "#{@candidate_mail.from}",
subject: "#{@candidate_mail.subject}",
body: "#{@candidate_mail.body}",
content_type: "text/html",
important: true,
inline_css: true,


FormObjects would be the way to go not save to your DB. Chris did a screencast for just this use case:

As for the image url: depends. Too little info to give a complete answer, but likely it's not a public url. See into the gem you use for file uploading for a "make public url" option.

I can send the email, the problem is the image is broken in the received email. I have seen documentation of how to add attachments to email, but that's not what I want because those are normally refer to public file or something or they hard code it. I use summernote to save the text and image, and they render properly in view, but the image shows broken when it's being sent out as an email. For your information, the image is encoded in Base 64 when save into database.

Login or Create An Account to join the conversation.

Subscribe to the newsletter

Join 30,242+ developers who get early access to new screencasts, articles, guides, updates, and more.

    By clicking this button, you agree to the GoRails Terms of Service and Privacy Policy.

    More of a social being? We're also on Twitter and YouTube.