What I Learned Today
In Ruby 1.8.7, comments inside ERB totally own. I have a site I'm working on with a legacy Rails app. The app runs under 1.8.6 and 1.8.7, but the layout's all jacked up under 1.8.7. That didn't make a lot of sense to me -- why would the layout get messed up?
Here's the culprit:
<% view_cache :tag => 'tags' do %>
<% @popular_tags.each_with_index do |tag, index| %>
<li class="gray<%= @tag_shade.call(tag) %>"><%= " | " if index > 0 %>
<%= link_to "#{h tag.name} (#{tag.count})",
blog_tag_path(h(tag.name)), :rel => 'tag' %>
</li>
<% end # tags each %>
<% end # view cache tags %>
Please ignore the faults in the code above: like I said, legacy. The issue is those comments after each end tag. In 1.8.6, that worked fine. When I took over the app and used 1.8.7, they caused the whole block not to render. I removed them, and everything worked.
Published: