How to comment code in Rails views?

<% code code # comment %> USED to work but I think that was accidental.

You were always supposed to put comments in separate comment tags <%# comment %>

Note NO SPACE before the pound.

Now the old loophole is closed (I forget whether 'now' means Ruby 1.8 or Rails 3 or what) so that:

<% code code  #  this runs too %>
<% # also runs %>
<%# the only way to comment out %>

I use this all the time

<%# This is a comment %>

The reason Ruby code would be executed inside <!-- --> HTML comments is because all of the server side code (ie. Ruby) is interpreted first, and then the output is sent to the client, at which point the browser interprets <!-- --> as a comment. As the other answers said, use <% #comment %> to comment within a Rails view.