views:

43

answers:

3

As I'm playing with Rails and developing views I often want to comment out code. Simple enough with classes & models but views are a bit more tricky.

What's best way to comment code in a view so it's not interpreted by, well, anything... HTML gives us <!-- commented Rails code here --> though code enclosed here seems to get interpreted anyway?!? Or is there a more Railsy way?

A: 
<% #comment here %>

:D

huntaub
A: 

I use this all the time

<%# This is a comment %>
brad
A: 

The reason Ruby code would be executed inside <!-- --> HTML comments is because the server side code (ie. Ruby) is interpreted too, 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.

Daniel Vandersluis