I have some content which in the database has linebreaks stored and when I view my content on the browser using simple_format I see the content displaying with linebreaks which is good. The issue is that when I send email, the line breaks are removed and it all shows up on one line. Here’s my mailer..
def new_announcement(announcement)
@announcement = announcement
addresses = @announcement.email_list.split(',')
mail(:to => addresses, :from => @announcement.from_email, :subject => @announcement.title, :content_type => "text/html") do |format|
format.html
end
end
..and then in my view new_announcement.html.erb
<!DOCTYPE html>
<html>
<head>
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type" />
</head>
<body>
<p>
<%= simple_format @announcement.content %>
</p>
<div class="faint-display">
This announcement was sent via the iTeam Announcements page for DA (<%= link_to "http://goto/iteam", "goto/iteam" %>)
</div>
</body>
</html>
The content for an announcement shows up on one line and not the way it does with linebreaks in the browser. Is there something I’m doing wrong? Thanks!
Ok, so figured it out. Turns out that the email view has no idea of the layout (CSS source) or any helper methods in the application so you need to explicitly mention those. This is what i have not and it works great!