So I have this file:
<h1>Calendar view</h1>
<div class="events">
<% @events.each do |e| %>
<%= raw(e.content)%>
<% end %>
</div>
<br />
<div class="messages">
<% @messages.each do |m| %>
<%= raw(m.content)%>
<% end %>
</div>
With @events and @messages being valid instance variables in the controller…but when I go to the page the html looks like this:
<h1>Calendar view</h1>
<div class="events">
<br>
<div class="messages">
This is another message test
</div
Event Content
</div>
I’m confused. Maybe I’m missing something obvious?
The problem is that
raw()will output raw HTML content. The Rails template engine will try to merge that with the.erbtemplate you supplied.Therefore, if either
m.contentore.contentare malformed, you will most likely get unexpected output.The best way would be to look for syntax errors, especially missing closing elements.